1 -- Recv function details
# Include <sys/socket. h> ssize_t Recv (INT socket, void * buffer, size_t length, int flags); Return Value:> 0: data is read successfully. Return Value indicates the number of bytes read this time; = 0: this indicates that no data can be read from the current interface and is disabled by the peer.-1: failed to read data. The system sets the errno value, for specific error causes and countermeasures, refer to errno;
When the Recv function returns-1, you must determine errno to determine the response. Next I will try to explain these errno and their causes.
Eagain or ewouldblock
Cause: this error code is generated when the socket is set to a non-blocking link and no data is readable on the current interface.
Countermeasure: if you do not close the current link, place the FD in the listening queue. Wait until it becomes readable and then read it again.