[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6.3 SDLNet_AddSocket

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
The socket set to add this socket to
sock
the socket to add to the socket set

Add a socket to a socket set that will be watched. TCP and UDP sockets should be added using the corrosponding macro (as in SDLNet_TCP_AddSocket for a TCP socket). The generic socket function will be called by the TCP and UDP macros. Both TCP and UDP sockets may be added to the same socket set. TCP clients and servers may all be in the same socket set. There is no limitation on the sockets in the socket set, other than they have been opened.

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

 
// 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:
3.6.1 SDLNet_AllocSocketSet, 3.6.4 SDLNet_DelSocket, 3.6.5 SDLNet_CheckSockets, 4.5 SDLNet_SocketSet, 4.3 UDPsocket, 4.2 TCPsocket



This document was generated on November, 3 2009 using texi2html