SYNOPSIS
|
DESCRIPTION
AG_Net provides a cross-platform interface to network sockets, DNS and other network-related functions. Available backends include "bsd", "dummy", "winsock1" and "winsock2". The default backend is selected based on present platform capabilities. |
NETWORK ADDRESSES
The AG_NetResolve() function looks up a specified host hostname and port number (or service name) port. If the lookup is successful, the results are returned as a list of addresses. Optional flags include:
The AG_NetGetIfConfig() function returns the list of addresses associated with local network interfaces (i.e., the list of addresses that would be displayed by ifconfig(8) under Unix). If the call is unsupported on the present platform, the function returns NULL. The AG_NetAddrList structure stores a list of network addresses. The AG_NetAddrListNew() function returns an empty, newly allocated list, AG_NetAddrListClear() removes all addresses from the given list and AG_NetAddrListFree() releases all resources allocated by the list. The AG_NetAddr structure stores a single network address and a port number. The AG_NetAddrNew() function returns a newly-allocated address. AG_NetAddrDup() returns a newly-allocated duplicate of a. AG_NetAddrCompare() evaluates to 0 if a and b represent the same address and port, otherwise a non-zero value (suitable for sorting) is returned. AG_NetAddrIsAny() returns 1 if the address represents "*" (any address). The AG_NetAddrNumerical() function returns a pointer to an (internally-managed) string buffer containing a numerical representation of the address. The buffer will remains valid until the AG_NetAddr is freed. The AG_NetAddrFree() routine destroys all resources allocated by a. |
SOCKETS
The AG_NetSocketNew() function creates an endpoint for communication, returning a socket descriptor on success. The af argument indicates the address family of the socket:
The proto argument is an optional protocol number (see protocols(5)). The type argument may be set to:
The AG_NetSocketFree() function closes a socket, releasing all associated resources. The AG_NetConnect() call establishes a connection between sock and a remote host (specified as a list containing one or more addresses to try). The AG_NetBind() call assigns a local protocol address addr, to the socket sock. The AG_NetAccept() function should be called on a socket that was previously assigned a local address. From the queue of pending connections, AG_NetAccept() extracts the first connection request and returns a newly-created socket for the connection. The AG_NetClose() routine closes the connection on sock (without destroying the socket). The AG_NetRead() and AG_NetWrite() routines move data between the socket and a specified buffer data of size bytes. On success, 0 is returned, and the number of bytes successfully read/written is returned in the nRead and nWrite argument (which can be NULL). The AG_NetGetOption() function returns the current value of the socket option opt into data. AG_NetSetOption() sets the specified socket option to the contents of data. The AG_NetGetOptionInt() and AG_NetSetOptionInt() shorthands accept integer arguments for int socket options. Available socket options are as follows (unless indicated otherwise, int is the data type).
The argument to AG_NET_ACCEPTFILTER is defined as follows:
|
POLLING AND SOCKET SETS
STRUCTURE DATA
SEE ALSO
HISTORY
![]() ![]() |