accept a connection on a socket
cc ... -lsocket
int accept(s, addr, addrlen)
struct sockaddr *addr;
accepts a connection on a socket.
The s argument is a socket
that has been created with
bound to an address 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 s
and allocates a new file descriptor for the socket.
If no pending connections are present on the queue,
and the socket is not marked as non-blocking,
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.
The accepted socket,
may not be used
to accept more connections.
The original socket s remains open.
The addr argument 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 parameter
is determined by the "communications domain".
for more information.)
The 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
This call is used with connection-based socket types,
currently with SOCK_STREAM.
The call returns -1 on error. If it succeeds it returns a non-negative
integer which is a descriptor for the accepted socket (ns,
will fail if:
addr is not readable or writable
Socket is not in a state that can accept connections
The I/O request is non-blocking
but needs to block to wait for resources to become available.
Socket is not connected.
This is either a bad connection indiation
or accept disconnection with a bad ack.
Out of STREAMS resources
The socket number specified by s is
greater than the maximum number of configured sockets.
Cannot allocate inode for socket.
The socket is already in the process of disconnecting.
Unexpected interrupt received.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003