AN_CONNECT_TOSOCKADDR(3)

NAME

an_connect_tosockaddr - connect to an outgoing address

SYNOPSIS

#include <antinat.h>

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

DESCRIPTION

The an_connect_tosockaddr(3) function is used to connect to the specified address at the specified port. an_connect_tohostname(3) should be used in preference to this function, because it allows name resolution to be deferred to the proxy where possible.

s is a socket previously created with an_new_connection(3) call.

address is a filled out sockaddr structure, containing an address family, address, and port that a connection should be made to. 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

Although there is planned support for non-blocking sockets in a future release, this call should be considered a blocking call. A non-blocking socket will be silently (and temporarily) changed to a blocking one to process the connection.

RETURN VALUE

This call returns AN_ERROR_SUCCESS to indicate successful completion.

ERRORS

AN_ERROR_AUTH
    The proxy would not accept the authentication credentials that were supplied to it.

AN_ERROR_INVALIDARG
    The socket handle or sockaddr structure is invalid; or structures of this length are not supported by the library.

AN_ERROR_NAMERESOLVE
    Could not resolve proxy hostname.

AN_ERROR_NOTSUPPORTED
    This call cannot be made on the type of socket, such as the authentication scheme required is not supported by this type of proxy, or the address type is not supported by this type of proxy.

AN_ERROR_ORDER
    This call must be called without a currently open connection, binding, listening, or accepting call.

AN_ERROR_NETWORK
    Could not read information from the network; a network error occurred.

AN_ERROR_PROXY
    The proxy failed to successfully process the connection.

SEE ALSO

an_close(3), an_connect_tohostname(3) an_new_connection(3)

AUTHOR

Malcolm Smith <malxau@users.sourceforge.net>