AN_BIND_TOSOCKADDR(3)

NAME

an_bind_tosockaddr - bind to an incoming address

SYNOPSIS

#include <antinat.h>

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

DESCRIPTION

The an_bind_tosockaddr(3) function is used allow incoming connections from the specified address. In order to accept any incoming connection, an_listen(3) must be called on the bound socket. For proxy-based connections, only one incoming connection is allowed on any listening socket. Accepting a connection will use the primary socket for communication and will not create any other socket.

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 an incoming connection should be allowed from.

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 is invalid, or the address structure doesn't point to anything.

AN_ERROR_NAMERESOLVE
    Could not resolve the proxy hostname into an address.

AN_ERROR_NOTSUPPORTED
    This call cannot be made on the type of socket, or cannot return socket information for this type of connection.

AN_ERROR_ORDER
    This call must be called without having performed any operation on the socket other than an_new_connection(3).

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

AN_ERROR_PROXY
    The proxy failed to successfully process the incoming connection.

SEE ALSO

an_accept(3), an_bind_tohostname(3), an_new_connection(3)

AUTHOR

Malcolm Smith <malxau@users.sourceforge.net>