SockRecvFrom

The SockRecvFrom() call receives data on a socket.

Syntax:

>>--SockRecvFrom(socket, var, len--+-----------+--, address)-------------><
                                   +--, 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 present on the socket. The data is returned but not consumed. The subsequent receive operation thus sees the same data.

address

is a stem variable specifying the address of the sender from which the data is received, unless it is a null address.

SockRecvFrom() receives data on a socket with descriptor socket and stores it in a Rexx variable named var. It applies to any socket type, whether connected or not.

SockRecvFrom() returns the length of the incoming message or data. If a datagram is too long to fit the supplied buffer, the excessive data is discarded. No data is discarded for stream sockets. If data is not available at socket, the SockRecvFrom() call waits for a message to arrive 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 -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.

EINVAL

Invalid argument.

EWOULDBLOCK

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

Note: SockRecvFrom() interfaces with the C function recvfrom().