SockRecv

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

Syntax:

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

where:

socket

is the socket descriptor.

var

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

len

is the maximum amount of data to be read.

flags

is a blank-delimited list of options:

MSG_OOB

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

MSG_PEEK

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:

ENOTSOCK

socket is not a valid socket descriptor.

EINTR

Interrupted system call.

EINVAL

Invalid argument.

EWOULDBLOCK

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().