socket 接收图片数据

来源:互联网 发布:pc淘宝首页尺寸大小 编辑:程序博客网 时间:2024/05/18 09:07
int RecvImageData(SOCKET socket,char *pImageData,int ImageSize)
{
int nCount = 0;


int nRet = 0;
while (nCount < ImageSize)
{
nRet = ::recv(socket, (char *)pImageData + nCount, ImageSize - nCount, 0);
if (SOCKET_ERROR == nRet)
{
int iRet = WSAGetLastError();
if (iRet == WSAEWOULDBLOCK)
{
continue;
}
break;
}
else if (0 == nRet)//对方SOCKET已关闭
{
break;
}
else if (nRet > 0)
{
nCount += nRet;
}
}
return nCount;
}
原创粉丝点击