int accept(int s, struct sockaddr *addr, int *addrlen);
The argument s is a socket that has been created with socket.3n and bound to an address with bind.3n and that is listening for connections after a call to listen.3n accept() extracts the first connection on the queue of pending connections, creates a new socket with the properties of s, and allocates a new file descriptor, ns, for the socket. If no pending connections are present on the queue and the socket is not marked as non-blocking, accept() blocks the caller until a connection is present. If the socket is marked as non-blocking and no pending connections are present on the queue, accept() returns an error as described below. accept() uses the netconfig.4 file to determine the STREAMS device file name associated with s. This is the device on which the connect indication will be accepted. The accepted socket, ns, is used to read and write data to and from the socket that connected to ns; it is not used to accept more connections. The original socket (s) remains open for accepting further connections.
The argument addr is a result parameter that is filled in with the address of the connecting entity as it is known to the communications layer. The exact format of the addr parameter is determined by the domain in which the communication occurs.
addrlen is a value-result parameter. Initially, it contains the amount of space pointed to by addr; on return it contains the length in bytes of the address returned.
accept() is used with connection-based socket types, currently with SOCK_STREAM.
It is possible to select.3c or poll.2 a socket for the purpose of an accept() by selecting or polling it for a read. However, this will only indicate when a connect indication is pending; it is still necessary to call accept().
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 21/April/97