1. The return value of the recev () function:
> 0: received data size;
= 0: the connection is closed;
<0: Error.
In case of error,
Under these three errors, the connection is considered to be normal and continue to receive
if(errno == EINTR ||(errno == EAGAIN)||errno == EWOULDBLOCK)
continue;
if(FD_ISSET(connfd,&r_set)
{
int irecv,iunrecv;
iunrecv = length;
while(iunrecv>0)
{
irecv = recv(concfd,buff,iunrecv,0)
if(irecv==0)
{
printf("recv error:%s",strerror(errno));
return -1;
}
if(irecv<0)
{
if(errno == EINTR ||(errno == EAGAIN)||errno == EWOULDBLOCK)
continue;
printf("recv error:%s",strerror(errno));
return -1;
}
iunrecv -= irecv;
buff += irecv;
}
}