AN_GETSOCKNAME

Section: Antinat Programmer's Manual (3)
Updated: 2005-01-03
Index Return to Main Contents
 

NAME

an_getsockname - fetch the public address the local client  

SYNOPSIS

#include <antinat.h>

int an_getsockname(ANCONN s, struct sockaddr *address, int length);  

DESCRIPTION

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.

length is the length of the sockaddr structure, as determined by sizeof.  

NOTES

Do not call this function without firstly having a connected or bound socket; and do not assume that an address will be available on different types of proxy.  

RETURN VALUE

This call returns AN_ERROR_SUCCESS to indicate successful completion.  

ERRORS

AN_ERROR_INVALIDARG
The socket handle or sockaddr structure is invalid; or structures of this length are not supported by the library.
AN_ERROR_NETWORK
The information is not available with this network configuration.
AN_ERROR_NOMEM
The socket information required more space than the length parameter indicated the address parameter has.
AN_ERROR_NOTSUPPORTED
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.
AN_ERROR_ORDER
This call must be called after a connection or an bind operation.
 

SEE ALSO

an_bind_tohostname(3), an_bind_tosockaddr(3), an_connect_tohostname(3), an_connect_tosockaddr(3), an_getpeername(3), an_new_connection(3)  

AUTHOR

Malcolm Smith <malxau@users.sourceforge.net>


 

Index

NAME
SYNOPSIS
DESCRIPTION
NOTES
RETURN VALUE
ERRORS
SEE ALSO
AUTHOR

Time: 14:19:44 GMT, January 09, 2005