The SockRecv() call receives data on a connected socket.


>>--SockRecv(socket, var, len--+-----------+--)--------------------------><
                               +--, flags--+



is the socket descriptor.


is the name of a Rexx variable to receive the data.


is the maximum amount of data to be read.


is a blank-delimited list of options:


reads any out-of-band data on the socket.


peeks at the data on the socket. The data is returned but not removed, so the subsequent receive operation sees the same data.

SockRecv() receives data on a socket with descriptor socket and stores it in the Rexx variable var. It applies only to connected sockets. For information on how to use SockRecv() with datagram and raw sockets, see Datagram or raw sockets.

SockRecv() returns the length of the incoming data. If a datagram is too long to fit the buffer, the excessive data is discarded. No data is discarded for stream sockets. If data is not available at socket, the SockRecv() call waits for a message and blocks the caller unless the socket is in nonblocking mode. See SockIoctl() for a description of how to set the nonblocking mode.

Return values:

If successful, the length of the data in bytes is returned. The value 0 indicates that the connection is closed. The value -1 indicates an error. You can get the specific error code SockSock_Errno() or SockPSock_Errno(). Possible values are:


socket is not a valid socket descriptor.


Interrupted system call.


Invalid argument.


socket is in nonblocking mode and no data is available, or the SO_RCVTIMEO option has been set for socket and the timeout expired before any data arrived.

Note: SockRecv() interfaces to the C function recv().