Recv
Purpose
- Read out-of-band data
- Peek at the incoming data without removing it from the buffer
On a datagram socket, if more than the number of bytes requested is available, Recv discards the excess bytes. If less than the number of bytes requested is available, Recv returns the number of bytes currently available. If data is not available at the socket, Recv waits for data to arrive and blocks the caller, unless the socket is in nonblocking mode.
On a stream socket, if the data length in the return string is zero, the other side has closed the socket.
Parameters
- socketid
- is the identifier of the socket.
- maxlength
- is the maximum length of data to be received. This is a number of bytes between 1 and 100000. If a number larger than the upper limit of 100000 is given, it will be replaced with 100000. If not specified, the default of 10000 is used.
- recvflags
- are flags that control the Recv operation:
- MSG_OOB or OOB or OUT_OF_BAND
- Read out-of-band data on the socket. Only AF_INET stream sockets support out-of-band data.
- MSG_PEEK or PEEK
- Look at the data on the socket but do not change or destroy it. The next call to Recv can read the same data.
- ''
- Receive the data. No flag is set. This is the default.
Return Values
If successful, this function returns a string containing return code 0, the length of the data received, and the data received. If unsuccessful, this function returns a string containing a nonzero return code, an error name, and an error message.
Examples
- Call
- Return Values
Socket('Recv',6)'0 21 This is the data line'Socket('Recv',6,,'PEEK OOB')'0 24 This is out-of-band data'
The C socket call is: recv(s, buf, len, flags)
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.
