sdlNetUdpRecv function

int sdlNetUdpRecv(
  1. Pointer<UDPsocket> sock,
  2. Pointer<UDPpacket> packet
)

Receive a single packet from a UDP socket.

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.

\param sock the UDP socket to receive packets on. \param packet a single packet to receive data into from the network. \returns 1 if a new packet is available, or -1 on error. 0 means no packets were currently available.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_UDP_Send \sa SDLNet_UDP_RecvV

extern DECLSPEC int SDLCALL SDLNet_UDP_Recv(UDPsocket sock, UDPpacket *packet)

Implementation

int sdlNetUdpRecv(Pointer<UDPsocket> sock, Pointer<UDPpacket> packet) {
  final sdlNetUdpRecvLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(Pointer<UDPsocket> sock, Pointer<UDPpacket> packet),
      int Function(Pointer<UDPsocket> sock,
          Pointer<UDPpacket> packet)>('SDLNet_UDP_Recv');
  return sdlNetUdpRecvLookupFunction(sock, packet);
}