Tao.Sdl SDK Documentation

SdlNet.SDLNet_TCP_GetPeerAddress Method 

Get the remote host address and port number

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

Parameters

sock
This is a valid TCPsocket.

Return Value

an IPaddress. NULL is returned on errors, or when sock is a server socket.

Remarks

Get the Peer's (the other side of the connection, the remote side, not the local side) IP address and port number.

Binds to C-function call in SDL_net.h:

            extern DECLSPEC IPaddress * SDLCALL SDLNet_TCP_GetPeerAddress(TCPsocket sock)
            

Example

            // get the remote IP and port
            //TCPsocket new_tcpsock;
            IPaddress *remote_ip;
            remote_ip=SDLNet_TCP_GetPeerAddress(new_tcpsock);
            if(!remote_ip) {
            printf("SDLNet_TCP_GetPeerAddress: %s\n", SDLNet_GetError());
            printf("This may be a server socket.\n");
            }
            else {
            // print the info in IPaddress or something else...
            }
            

See Also

SdlNet Class | Tao.Sdl Namespace | SDLNet_TCP_Open | SDLNet_TCP_Accept | SdlNet.IPaddress | SdlNet.TCPsocket