/********************************************************************** * 函數名稱: * 功能描述: 接收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); }