sdlNetAddSocket function

int sdlNetAddSocket(
  1. Pointer<SdlNetSocketSet> set,
  2. SdlNetGenericSocket sock
)

Add a socket to a socket set, to be checked for available data.

Generally you don't want to call this generic function, but rather the specific, inline function that wraps it: SDLNet_TCP_AddSocket() or SDLNet_UDP_AddSocket().

This function will fail if you add a socket to the set when the set already has its maximum number of sockets added, but otherwise it will always succeed.

If sock is NULL, nothing is added to the set; this lets you query the number of sockets currently contained in the set.

\param set the socket set to add a new socket to. \param sock the socket to add to the set. \returns the total number of sockets contained in the set (including this new one), or -1 if the set is already full.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_TCP_AddSocket \sa SDLNet_UDP_AddSocket \sa SDLNet_DelSocket \sa SDLNet_TCP_DelSocket \sa SDLNet_UDP_DelSocket \sa SDLNet_CheckSockets

extern DECLSPEC int SDLCALL SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock)

Implementation

int sdlNetAddSocket(Pointer<SdlNetSocketSet> set, SdlNetGenericSocket sock) {
  final sdlNetAddSocketLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(Pointer<SdlNetSocketSet> set, SdlNetGenericSocket sock),
      int Function(Pointer<SdlNetSocketSet> set,
          SdlNetGenericSocket sock)>('SDLNet_AddSocket');
  return sdlNetAddSocketLookupFunction(set, sock);
}