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

### 3.3.4 SDLNet_TCP_GetPeerAddress

`IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)`

sock
  This is a valid TCPsocket.

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

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

    // 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:
3.3.1 SDLNet_TCP_Open, 3.3.3 SDLNet_TCP_Accept, 4.1 IPaddress, 4.2 TCPsocket

This document was generated on November, 3 2009 using texi2html