in sample_app/onvif_camera_mock/artifacts/wsdd/src/net_utils.c [709:754]
int recv_loop(int sd, char *buf, size_t buf_len, int timeout_in_usec, int count_loop)
{
int n, len;
if( !buf || !buf_len )
{
errno = EINVAL;
return -1;
}
len = buf_len;
while( (len > 0) && (count_loop-- > 0) )
{
n = recv(sd, buf, len, 0);
if( (n == -1) && (errno != EAGAIN) )
return -1; // error reading
if( n == 0 )
return -1; // the connection is already closed by the client
if( n > 0 )
{
buf += n;
len -= n;
}
if(len <= 0)
break;
usleep(timeout_in_usec);
}
return (buf_len - len); //return length of data reading
}