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

3.6.5 SDLNet_CheckSockets

int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)

The socket set to check
The amount of time (in milliseconds).
0 means no waiting.
-1 means to wait over 49 days! (think about it)

Check all sockets in the socket set for activity. If a non-zero timeout is given then this function will wait for activity, or else it will wait for timeout milliseconds.

NOTE: "activity" also includes disconnections and other errors, which would be determined by a failed read/write attempt.

Returns: the number of sockets with activity. -1 is returned on errors, and you may not get a meaningful error message. -1 is also returned for an empty set (nothing to check).

// Wait for up to 1 second for network activity
//SDLNet_SocketSet set;
int numready;

numready=SDLNet_CheckSockets(set, 1000);
if(numready==-1) {
    printf("SDLNet_CheckSockets: %s\n", SDLNet_GetError());
    //most of the time this is a system error, where perror might help you.
else if(numready) {
    printf("There are %d sockets with activity!\n",numready);
    // check all sockets with SDLNet_SocketReady and handle the active ones.

See Also:
3.6.6 SDLNet_SocketReady, 3.6.3 SDLNet_AddSocket, 3.6.4 SDLNet_DelSocket, 3.6.1 SDLNet_AllocSocketSet, 4.5 SDLNet_SocketSet, 4.3 UDPsocket, 4.2 TCPsocket

This document was generated on November, 3 2009 using texi2html