SockAccept

The SockAccept() call accepts a connection request from a remote host.

Syntax:

>>--SockAccept(socket--+-------------+--)--------------------------------><
                       +--, address--+

where:

socket

is the socket descriptor created with the SockSocket() call. It is bound to an address using the SockBind() call and must be enabled to accept connections using theSockListen() call.

address

is a stem variable that contains the socket address of the connection client when the SockAccept() call returns. This parameter is optional.

SockAccept() is used by a server in a connection-oriented mode to accept a connection request from a client. The call accepts the first connection on its queue of pending connection requests. It creates a new socket descriptor with the same properties as socket and returns it to the caller. This new socket descriptor cannot be used to accept new connections. Only the original socket can accept more connection requests.

If the queue has no pending connection requests, SockAccept() blocks the caller unless the socket is in nonblocking mode. If no connection requests are queued and the socket is in nonblocking mode, SockAccept() returns a value of -1 and sets the return code to the value EWOULDBLOCK.

You cannot get information on requesters without calling SockAccept(). The application cannot tell the system from which requesters it will accept connections. The caller can close a connection immediately after identifying the requester.

The SockSelect() call can be used to check the socket for incoming connection requests.

Return Values:

A positive value indicates successful execution of the call. The value -1 indicates an error. You can get the specific error code by calling SockSock_Errno() or SockPSock_Errno(). Possible values:

ENOTSOCK

socket is not a valid socket descriptor.

EINTR

Interrupted system call.

EINVAL

SockListen() was not called for socket.

EOPNOTSUPP

socket is not connection-oriented.

EWOULDBLOCK

socket is in nonblocking mode, and there are no connection requests queued.

ECONNABORTED

The software caused a connection close.

Note: SockAccept() interfaces with the C function accept().