accept(2) DG/UX 4.30 accept(2)
NAME
accept - Accept a connection on a socket.
SYNOPSIS
#include <sys/socket.h>
int accept (s, addr, addrlen)
int s;
struct sockaddr * addr;
int * addrlen;
PARAMETERS
s File descriptor of socket listening for
connection requests.
addr Structure to receive the address of newly
connected peer.
addrlen On input contains the number of bytes
available for the peer address; updated to
indicate the number of bytes returned.
DESCRIPTION
The argument <s> is the file descriptor of a socket that has
been:
* Created with the socket() system call.
* Bound to an address with bind().
* Made to listen for connections with listen().
Accept extracts the first connection on the queue of pending
connections, creates a new socket of the same type (e.g.
SOCK_STREAM) as <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 non-blocking and no pending connections
are present on the queue, accept returns an error as
described below. The accepted socket, <ns>, will be in the
connected state. The original socket <s> remains open
listening for more connections.
The argument <addr> is a result parameter that is filled in
with the address of the connecting entity, as known to the
communications layer. The exact format of the <addr>
Licensed material--property of copyright holder(s) Page 1
accept(2) DG/UX 4.30 accept(2)
parameter is determined by the domain in which the
communication is occurring. See related documentation for a
descripton of address formats for each domain. <Addrlen> is
a value/result parameter; it should initially contain the
amount of space pointed to by <addr>; on return it will
contain the actual length (in bytes) of the address
returned. If addrlen is zero, the pointer will be ignored.
If the address buffer is too small to hold all of the
address, the address will be truncated.
This call is used with connection-based socket types,
currently with SOCK_STREAM.
A select() system call can be issued on a listening socket
for notification of connnection requests.
ACCESS CONTROL
None.
RETURN VALUE
<ns> The call was successful. <Ns> is a non-
negative integer that is a descriptor for the
accepted socket.
-1 An error occurred. Errno is set to indicate
the error.
EXCEPTIONS
Errno may be set to one of the following error codes:
EBADF The argument <s> is not an active, valid
descriptor.
ENOTSOCK The descriptor references a file, not a
socket.
EMFILE No more user file descriptors available, the
per-process limit has been reached.
ENFILE No more system file descriptors available,
the system limit has been reached.
EINVAL The socket <s> is not in the listen state.
EOPNOTSUPP The referenced socket is not of type
Licensed material--property of copyright holder(s) Page 2
accept(2) DG/UX 4.30 accept(2)
SOCK_STREAM.
EFAULT The addr parameter is not in a writable part
of the user address space.
ECONNABORTED Listen operation aborted by system.
EAGAIN The socket is marked non-blocking and no
connections are present to be accepted.
EINTR The call was interrupted by a signal.
SEE ALSO
The related manual sections: inet(3N), inet(6F),
unix_ipc(6F), bind(2), connect(2), listen(2), select(2),
socket(2).
Licensed material--property of copyright holder(s) Page 3