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

### 3.3.3 SDLNet_TCP_Accept

`TCPsocket SDLNet_TCP_Accept(TCPsocket server)`

server
  This is the server TCPsocket which was previously created by
  SDLNet_TCP_Open.

Accept an incoming connection on the server TCPsocket.
Do not use this function on a connected socket. Server sockets are never connected to a remote host. What you get back is a new TCPsocket that is connected to the remote host.
This is a non-blocking call, so if no connections are there to be accepted, you will get a NULL TCPsocket and the program will continue going.

Returns: a valid TCPsocket on success, which indicates a successful connection has been established. NULL is returned on errors, such as when it's not able to create a socket, or it cannot finish connecting to the originating host and port. There also may not be a connection attempt in progress, so of course you cannot accept nothing, and you get a NULL in this case as well.

    // accept a connection coming in on server_tcpsock
    TCPsocket new_tcpsock;

    new_tcpsock=SDLNet_TCP_Accept(server_tcpsock);
    if(!new_tcpsock) {
        printf("SDLNet_TCP_Accept: %s\n", SDLNet_GetError());
    }
    else {
        // communicate over new_tcpsock
    }

See Also:
3.3.1 SDLNet_TCP_Open, 3.3.4 SDLNet_TCP_GetPeerAddress, 3.3.2 SDLNet_TCP_Close, 4.2 TCPsocket

This document was generated on November, 3 2009 using texi2html