Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
recv() z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference SC27-3660-00 |
|
The recv() call receives data on a socket with descriptor s and stores it in a buffer. The recv() call applies only to connected sockets. This call returns the length of the incoming message or data. If data is not available for socket s, and s is in blocking mode, the recv() call blocks the caller until data arrives. If data is not available and s is in nonblocking mode, recv() returns a -1 and sets errno to EWOULDBLOCK. See fcntl() or ioctl() 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 and call this function until all data has been received.
Return valuesIf successful, the byte length
of the message or datagram is returned. The value -1 indicates
an error. The value 0 indicates connection closed. Errno identifies
the specific error.
Related callsconnect(), fcntl(), getsockopt(), ioctl(), read(), readv(), recvfrom(), recvmsg(), select(), selectex(), send(), sendmsg(), sendto(), setsockopt(), socket(), write(), writev() |
Copyright IBM Corporation 1990, 2014
|