#include <cafe.h> #include <cafe/network.h> int SOAccept(int fd, struct sockaddr *addr, int *addrlen);
|fd||Socket descriptor created with
|addr||Pointer to a
|addrlen||Initially contains the size of the structure pointed to by addr; upon return will contain the actual length of the address returned (in bytes).|
A descriptor for the accepted socket that is a non-negative integer. Upon an error,
-1 is returned, and
errno is set appropriately.
||Socket resource manager busy processing requests.|
||Socket library is not initialized.|
||Insufficient memory in the stack.|
||Too many sockets open. No more socket file descriptors available.|
- If addr is not
||The socket is marked non-blocking and no connections are present to be accepted.|
||A connection arrived, but it was closed while waiting on the listen queue.|
||The operation was aborted. When a socket is closed, operations that are blocked on the socket are aborted.|
||Specified argument is not a socket.|
||Internal API error, invalid error code.|
||Internal API error.|
The argument fd is a socket that has been created with
SOSocket, is bound to an address
SOBind and is listening for connections after a
the first connection out of the queue of pending connections, creates a new socket with the same properties as
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,
SOAccept blocks the caller until a connection is present. If the
socket is marked non-blocking and no pending connections are present on the queue,
SOAccept returns an error as described above. The accepted socket is used to read
and write data to and from the socket which connected to this one; it is not used to accept more connections. The original socket
s remains open for accepting further
The argument addr is a result parameter that is filled in with the address of the connecting entity as known to the communications layer; i.e., the exact format of
addr parameter is determined by the domain in which the communication is occurring. 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 addr is
nothing is filled in; in this case, addrlen is not used, and should also be
NULL. This call is used with connection-based socket types, currently
It is possible to
SOSelect a socket for the purposes of performing an
SOAccept by selecting it for read.
|Callbacks||Do not call this function from any callback function.|
|Interrupt handler||Do not call this function from any interrupt handler.|
|Exception handler||Do not call this function from any exception handler.|
2012/10/09 Updated Errors section.
2012/08/15 Cleanup pass.
2011/07/11 Added Errors section.
2011/02/21 Initial version.