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;
}
{
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;
}