sdlNetUdpRecvV function

int sdlNetUdpRecvV(
  1. Pointer<UDPsocket> sock,
  2. Pointer<Pointer<UDPpacket>> packets
)

Receive a vector of pending packets 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 takes an array of packets but does not need to be allocated through SDLNet_AllocPacketV; if you supply your own array of packets you allocated individually, that is okay, as long as the last element in the array is NULL, so SDL_net knows the array bounds. The arrays returned by SDLNet_AllocPacketV are properly NULL-terminated for these purposes.

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 packets an array of packets, NULL terminated. \returns the number of packets read from the network, 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_SendV \sa SDLNet_UDP_Recv

extern DECLSPEC int SDLCALL SDLNet_UDP_RecvV(UDPsocket sock, UDPpacket **packets)

Implementation

int sdlNetUdpRecvV(
    Pointer<UDPsocket> sock, Pointer<Pointer<UDPpacket>> packets) {
  final sdlNetUdpRecvVLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(
          Pointer<UDPsocket> sock, Pointer<Pointer<UDPpacket>> packets),
      int Function(Pointer<UDPsocket> sock,
          Pointer<Pointer<UDPpacket>> packets)>('SDLNet_UDP_RecvV');
  return sdlNetUdpRecvVLookupFunction(sock, packets);
}