Receive a single packet from a UDP socket.
Defined in <SDL_net.h>
int SDLNet_UDP_Recv(UDPsocket sock, UDPpacket *packet);
UDPsocket | sock | the UDP socket to receive packets on. |
UDPpacket * | packet | a single packet to receive data into from the network. |
(int) Returns 1 if a new packet is available, or -1 on error. 0 means no packets were currently available.
The returned packets contain the source address and the channel they arrived on. If they did not arrive on a bound channel, the the channel will be set to -1.
The 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 returned.
This function does not block, so it can return 0 packets pending, which is not an error condition.
This function is available since SDL_net 2.0.0.