.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)accept.2 6.2 (Berkeley) %G%
accept \- accept a connection on a socket
ns = accept(s, addr, addrlen)
is a socket that has been created with
and is listening for connections after a
extracts the first connection
on the queue of pending connections, creates
a new socket with the same properties of
and allocates a new file descriptor,
for the socket. If no pending connections are
present on the queue, and the socket is not marked
blocks the caller until a connection is present.
If the socket is marked non-blocking and no pending
connections are present on the queue,
returns an error as described below.
to accept more connections. The original socket
is a result parameter that is filled in with
the address of the connecting entity,
as known to the communications layer.
parameter is determined by the domain in which the communication
is a value-result parameter; it should initially contain the
amount of space pointed to by
on return it will contain the actual length (in bytes) of the
is used with connection-based socket types, currently with SOCK_STREAM.
a socket for the purposes of doing an
by selecting it for read.
The call returns \-1 on error. If it succeeds it returns a non-negative
integer that is a descriptor for the accepted socket.
The \fIaccept\fP will fail if:
The descriptor is invalid.
The descriptor references a file, not a socket.
The referenced socket is not of type SOCK_STREAM.
The \fIaddr\fP parameter is not in a writable part of the
The socket is marked non-blocking and no connections
are present to be accepted.
bind(2), connect(2), listen(2), select(2), socket(2)