Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
read() z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference SC27-3660-00 |
|
The read() call reads data on a socket with descriptor s and stores it in a buffer. The read() call applies only to connected sockets. This call returns as many as len bytes of data. If fewer than the number of bytes requested is available, the call returns the number currently available. If data is not available for the socket s, and s is in blocking mode, the read() call blocks the caller until data arrives. If data is not available, and s is in nonblocking mode, read() returns a -1 and sets errno to EWOULDBLOCK. See ioctl(), or fcntl() for a description of how to set nonblocking mode. If a datagram packet is too long to fit in the supplied buffer, datagram sockets discard extra bytes. Stream sockets act like streams of information with no boundaries separating data. For example, if applications A and B are connected with a stream socket and Application A sends 1000 bytes, each call to this function can return 1 byte, or 10 bytes, or the entire 1000 bytes. Therefore, applications using stream sockets should place this call in a loop, calling this function until all data has been received.
Return valuesIf successful, the number
of bytes copied into the buffer is returned. The value 0 indicates that
the connection is closed. The value -1 indicates an error. Errno identifies
the specific error.
Related callsconnect(), fcntl(), getsockopt(), ioctl(), readv(), recv(), recvmsg(), recvfrom(), select(), selectex(), send(), sendmsg(), sendto(), setsockopt(), socket(), write(), writev() |
Copyright IBM Corporation 1990, 2014
|