READ
The READ call reads the data on a socket.
Data is processed as streams of information with no boundaries separating the data. For example, if programs A and B are connected and program A sends 1000 bytes, each call to this function can return any number of bytes up to the entire 1000 bytes. The number of bytes returned will be contained in RETCODE. Therefore, programs should place this call in a loop that repeats until all data has been received.
Example of READ call
SOC_FUNCTION DC CL16'READ'
S DS H
NBYTE DS F
BUF DS CL(length of buffer).
ERRNO DS F
RETCODE DS F
CALL DFHSOKET,(SOC_FUNCTION,S,NBYTE,BUF,ERRNO,RETCODE)
Input parameters
- SOC_FUNCTION
- A 16-byte character field containing READ. The field is left-justified and padded to the right with blanks.
- S
- A halfword binary number set to the socket descriptor of the socket that is going to read the data.
- NBYTE
- A fullword binary number set to the size of BUF. READ does not return more than the number of bytes of data in NBYTE even if more data is available.
Output parameters
- BUF
- On input, a buffer to be filled by completion of the call. The length of BUF must be at least as long as the value of NBYTE.
- ERRNO
- A fullword binary field. If RETCODE is negative, the field contains an error number. See Return codes for information about ERRNO return codes.
- RETCODE
- A fullword binary field that returns one of the following:
- Value
- Description
- 0
- A 0 return code indicates that the connection is closed and no data is available.
- >0
- A positive value indicates the number of bytes copied into the buffer.
- -1
- Check ERRNO for an error code.