AN_GETSOCKNAMESection: Antinat Programmer's Manual (3)
Index Return to Main Contents
The an_getsockname(3) function is used retrieve the public address of the local 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 an address, the socket must be connected to a remote host (via an_connect_tohostname(3) or an_connect_tosockaddr(3) ) or be bound to accept incoming connections with an_bind_tohostname(3) or an_bind_tosockaddr(3). Depending on the proxy protocol, a local address may not be available. On the basis that wrong information is worse than none, in these cases the function will fail. A bound socket should have an available address on SOCKS4 or SOCKS5; a connected socket may only have an available address on SOCKS5 (or SOCKS4, if your server is Antinat.) Given that you cannot control the proxy where your application may run, do not make assumptions about whether one will be available.
s is a socket previously created with an_new_connection(3) call, placed in the bound or connected state with one of an_bind_tohostname(3), an_bind_tosockaddr(3), an_connect_tohostname(3) or an_connect_tosockaddr(3).
address is a sockaddr structure, which will be filled with address family, address, and port that the local server is using for the connection. This can also be a typecast sockaddr_in6 structure, if Antinat has been compiled with IPv6 support.
- The socket handle or sockaddr structure is invalid; or structures of this length are not supported by the library.
- The 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 bind operation.
Malcolm Smith <email@example.com>
Time: 14:19:44 GMT, January 09, 2005