AN_GETPEERNAMESection: Antinat Programmer's Manual (3)
Index Return to Main Contents
The an_getpeername(3) function is used retrieve the public address of the remote client. Be careful when using this function; proxy-aware applications have an additional set of considerations over BSD-socket applications. Firstly, in order to have a peer address, the socket must be connected to a remote host (via an_connect_tohostname(3), an_connect_tosockaddr(3) or an_accept(3).) Secondly, when using an_connect_tohostname(3) the public address may not be known to the client library. On the basis that wrong information is worse than none, in these cases the function will fail. Whether or not an address is available is dependent on the proxy protocol; do not make assumptions about whether one will be available.
address is a sockaddr structure, which will be filled with address family, address, and port that the remote host is using for the connection. This can also be a typecast sockaddr_in6 structure, if Antinat has been compiled with IPv6 support.
Do not call this function without firstly having a connected or accepted socket; and do not assume that an address will be available if the connection was made with an_connect_tohostname(3).
- The socket handle or sockaddr structure is invalid; or structures of this length are not supported by the library.
- This information is not available with this network configuration.
- The socket information required more space than the length parameter indicated the address parameter has.
- This call cannot be made on the type of socket, such as the proxy type does not support the retrieval of this type of information.
- This call must be called after a connection or an accepted incoming connection.
Malcolm Smith <firstname.lastname@example.org>
Time: 14:19:44 GMT, January 09, 2005