|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
int SDLNet_UDP_Recv(UDPsocket sock, UDPpacket *packet)
Receive a packet on the specified sock socket.
The packet you pass in must have enough of a data size allocated for the incoming packet data to fit into. This means you should have knowledge of your size needs before trying to receive UDP packets.
The packet will have it's address set to the remote sender's address.
The socket's channels are checked in highest to lowest order, so if an address is bound to multiple channels, the highest channel with the source address bound will be retreived before the lower bound channels. So, the packets channel will also be set to the highest numbered channel that has the remote address and port assigned to it. Otherwise the channel will -1, which you can filter out easily if you want to ignore unbound source address.
Note that the local and remote channel numbers do not have to, and probably won't, match, as they are only local settings, they are not sent in the packet.
This is a non-blocking call, meaning if there's no data ready to be received the function will return.
Returns: 1 is returned when a packet is received. 0 is returned when no packets are received. -1 is returned on errors.
3.4.3 SDLNet_UDP_Bind, 3.4.6 SDLNet_UDP_Send, 3.4.8 SDLNet_UDP_SendV, 3.4.9 SDLNet_UDP_RecvV, 4.4 UDPpacket, 4.3 UDPsocket