基于Linux的socket编程模板(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-20 07:53 点击:次
{
printf("successfully send bytes %d\n",SERVER_PACK_LEN);
break;
}
else if( sendBytes <= 0 && errno != EINTR && errno != EWOULDBLOCK && errno != EAGAIN)
{
printf("disconnected or other errors!\n");
return -1;
}
else
{
continue;
}
}
// recv process result from server
while(1)
{
recvBytes = recv(g_hSocket,(uint8_t *)&rPack,RETURN_PACK_LEN,0);
if( recvBytes == RETURN_PACK_LEN )
{
break;
}
else if( recvBytes <=0 && errno != EINTR && errno != EWOULDBLOCK && errno != EAGAIN )
{
printf("disconnected or error occur!\n close the socket!\n");
return -1;
}
else
{
continue;
}
}
// check header
if ( memcmp( rPack.cmdHeader, TCP_CMD_HEADER_STR, TCP_CMD_HEADER_LEN ) != 0 )
{
printf("return pack header errror!\n");
return -2;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>