/**********************************************************************
* 函数名称:
* 功能描述: 接收H264视频数据(TCP方式)
* 输入参数: handle SOCKET句柄
MaxRecvLen 数据最大的接收长度
* 输出参数: buf 接收数据的缓存地址
len 接收数据的长度
* 返 回 值:0为成功,1为失败
* 其它说明:
***********************************************************************/
int RecvH264Data(int handle, char *buf, int *len, int MaxRecvLen)
{
int recvbytes;
int recvLen = MaxRecvLen;
while(1)
{
recvbytes = recv( handle, buf, recvLen, 0 );//MSG_DONTWAIT
if ( recvbytes <= 0 )
{
if(errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN)
{
LOGI( "Continue to!" );
usleep(100);
continue;
}
else
{
LOGI( "recv error!" );
return(1);
}
}
if(recvbytes == recvLen)
{
LOGI( "return TRUE : %d\n",recvbytes );
*len = recvbytes;
break;
}
else
{
LOGI( "recvbytes : %d\n",recvbytes );
recvLen -= recvbytes;
buf += recvbytes;
continue;
}
}
return(0);
}