SDLNet_AddSocket

Name

SDLNet_AddSocket -- add a socket to a socket set that will be watched.

Synopsis

#include "SDL_net.h"

int SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
int SDLNet_TCP_AddSocket(SDLNet_SocketSet set, TCPsocket sock);
int SDLNet_UDP_AddSocket(SDLNet_SocketSet set, UDPsocket sock);

set is the socket set to add this socket to.

sock is the socket to add to the socket set.

Return Value

Returns the number of sockets used in the set on success. -1 is returned on errors.

Example

// add two sockets to a socket set
//SDLNet_SocketSet set;
//UDPsocket udpsock;
//TCPsocket tcpsock;
int numused;

numused = SDLNet_UDP_AddSocket(set, udpsock);
if (numused == -1) {
    printf("SDLNet_AddSocket: %s\n", SDLNet_GetError());
    // perhaps you need to restart the set and make it bigger...
}

numused = SDLNet_TCP_AddSocket(set, tcpsock);
if (numused == -1) {
    printf("SDLNet_AddSocket: %s\n", SDLNet_GetError());
    // perhaps you need to restart the set and make it bigger...
}

See Also

SDLNet_AllocSocketSet, SDLNet_DelSocket, SDLNet_CheckSockets, SDLNet_SocketSet, UDPsocket, TCPsocket

SDLNet_AddSocket (last edited 2008-04-17 08:18:30 by localhost)