Tao.Sdl SDK Documentation

SdlNet.SDLNet_TCP_Accept Method 

Accept a connection on a server socket

[Visual Basic]
Public Shared Function SDLNet_TCP_Accept( _
   ByVal server As TCPsocket _
) As IntPtr
[C#]
public static IntPtr SDLNet_TCP_Accept(
   TCPsocket server
);

Parameters

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

Return Value

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.

Remarks

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. Accept an incoming connection on the given server socket. The newly created socket is returned, or NULL if there was an error.

Binds to C-function call in SDL_net.h:

            extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Accept(TCPsocket server)
            

Example

            // 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

SdlNet Class | Tao.Sdl Namespace | SDLNet_TCP_Open | SDLNet_TCP_Close | SDLNet_TCP_GetPeerAddress | SdlNet.TCPsocket