Accept

Read syntax diagramSkip visual syntax diagram SOCKET ( ' ACCEPT ' , socketid )

Purpose

Use the Accept function on a server to accept a connection request from a client. It is used only with stream sockets.

The Accept function accepts the first connection on the listening (passive) socket's queue of pending connections. Accept creates a new socket with the same properties as the listening socket and returns the new socket ID to the caller. If the queue has no pending connection requests, Accept blocks the caller unless the listening socket is in nonblocking mode. If no connection requests are queued and the listening socket is in nonblocking mode, Accept ends with return code 35 (EWOULDBLOCK). The new socket is in active mode and cannot be used to accept new connections. The original socket remains in passive mode and is available to accept more connection requests.

Parameters

socketid
is the identifier of the passive socket on which connections are to be accepted. This is a socket that was previously placed into passive mode (listening mode) by calling the Listen function.

Return Values

If successful, this function returns a string containing return code 0, the new socket ID, and the socket name. (The socket name is the socket's network address, which consists of the domain, port ID, and the IP address.) If unsuccessful, this function returns a string containing a nonzero return code, an error name, and an error message.

Examples

Call
Return Values
Socket('Accept',5)
'0 6 AF_INET 5678 9.4.3.2'

The C socket call is: accept(s, name, namelen)

Messages and Return Codes

For a list of REXX Sockets system messages, see REXX Sockets System Messages. For a list of REXX Sockets return codes, see REXX Sockets Return Codes.