.\" Copyright (c) 1983 The Regents of the University of California.
.\" Redistribution and use in source and binary forms are permitted
.\" provided that the above copyright notice and this paragraph are
.\" duplicated in all such forms and that any documentation,
.\" advertising materials, and other materials related to such
.\" distribution and use acknowledge that the software was developed
.\" by the University of California, Berkeley. The name of the
.\" University may not be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\" @(#)accept.2 6.4 (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)