#include <revolution/mp.h>
s32 MPSend ( const void* data, u32 length, u32 aidBits, u32 port, u32* restBits );
data |
Pointer to the data to be sent |
length |
Length of the data to be sent |
aidBits |
AID list of the send destinations |
port |
Port number that is sending the data |
restBits |
List of AIDs that need resends |
Returns the processing results. Returns a negative number if processing fails.
This function is used to send data. Blocking occurs until an attempt is made to send the Send Data. The results are stored in *restBits and returned.
Since MP_RESULT_OK is the return value even if the send attempt fails, be sure to determine whether or not data has been sent to all destinations based on whether or not restBits is 0.
The restBits bit is sometimes set even if sending succeeded. Conversely, if communications fail, the restBits bit is supposed to be set for certain, but if more than eight children are connected to the Wii there is no guarantee for this either. When a number of children are connected, you will need at times to confirm the arrival of data at the application level.
The value of restBits indicates any parties that must be resent to. Specifically, of the parties specified by aidBits, the corresponding bits of restBits are not set for those parties that are not connected or that were disconnected during communications. The reason for this is that resending to a disconnected party is pointless. Be sure to check whether other parties have been disconnected using a separate disconnect notification. Under MP communications, there is no guarantee that data sent immediately before a disconnect actually reaches the destination party.
When a connection notification arrives, set the aidBits to be sent to as part of the registration process conducted by the application, and when a disconnect notification arrives, perform removal processing and clear the bit in aidBits. Then, when sending data, decide whether to resend by looking at restBits. In the case of disconnected children, perform processing after reconnection (if necessary) under the assumption that data sent immediately before a disconnect may not have arrived. This is the basic design concept behind MP communications. Note that zero is always returned in restBits whenever a child is completely unconnected as a special case of the above.
The port number can be set to numbers 5 through 8 for raw communications and numbers 12 through 15 for sequential communications by the application.
For sequential communications, the properties are only guaranteed for connections of up to eight children. Connections of more than eight children are not guaranteed to have the sequential communications' advantage that successfully sent data always reaches its target.
2007/09/26 Changed the explanation about sequential communications.
2007/01/29 Added a description of restBits.
2006/08/22 Added a description of restBits.
2006/06/29 Initial version.
CONFIDENTIAL