- 论坛徽章:
- 0
|
while(1)
{
NEDataInd databuf;
memset(&databuf,0,sizeof(NEDataInd));
// Read one data package
int nLeng = sizeof(NEDataInd);
int nRet;
int idx = 0;
char *pbuf = (char*)&databuf;
//while(nLeng > 0)
//{
// printf("will receiv\r\n");
// nRet = recv(sock,pbuf+idx,nLeng,0);
// printf("recvlen=%d\r\n",nRet);
// if(nRet == 0 )
// {
// WriteLogA("Socket端口连接已经被关闭!\r\n");
// return 0;
// }
// if(nRet == SOCKET_ERROR)
// {
// if(errno != 10060)//not time out
// {
// return 0;
// }
// WriteLogA("Receive command response failed,socket error\r\n");
// continue;
// }
// idx += nRet;
// nLeng -= nRet;
//}
nRet = recv(sock,pbuf,nLeng,0);
}
我接收数据的代码就是那段注释代码。第一个数据包正常,第二个就一直在那里等待,是不是数据包的大小没有达到NEDataInd的大小就没有返回,一直在那里死等? |
|