sdlNetUdpBind function

int sdlNetUdpBind(
  1. Pointer<UDPsocket> sock,
  2. int channel,
  3. Pointer<IPaddress> address
)

Bind an address to the requested channel on the UDP socket.

Note that UDP sockets at the platform layer "bind" to a nework port number, but SDL_net's UDP sockets also "bind" to a "channel" on top of that, with SDLNet_UDP_Bind(). But the term is used for both.

If channel is -1, then the first unbound channel that has not yet been bound to the maximum number of addresses will be bound with the given address as it's primary address.

If the channel is already bound, this new address will be added to the list of valid source addresses for packets arriving on the channel. If the channel is not already bound, then the address becomes the primary address, to which all outbound packets on the channel are sent.

\param sock the UDP socket to bind an address to a channel on. \param channel the channel of the socket to bind to, or -1 to use the first available channel. \param address the address to bind to the socket's channel. \returns the channel which was bound, or -1 on error.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_UDP_Unbind

extern DECLSPEC int SDLCALL SDLNet_UDP_Bind(UDPsocket sock, int channel, const IPaddress *address)

Implementation

int sdlNetUdpBind(
    Pointer<UDPsocket> sock, int channel, Pointer<IPaddress> address) {
  final sdlNetUdpBindLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(
          Pointer<UDPsocket> sock, Int32 channel, Pointer<IPaddress> address),
      int Function(Pointer<UDPsocket> sock, int channel,
          Pointer<IPaddress> address)>('SDLNet_UDP_Bind');
  return sdlNetUdpBindLookupFunction(sock, channel, address);
}