MFC中socket编程时recv设置超时属性后,如果超时返回值是什么?谢谢大家...

发布网友 发布时间:2024-10-24 04:54

我来回答

2个回答

热心网友 时间:2024-10-24 06:12

超时,也是 返回: SOCKET_ERROR
用WSAGetLastError() 获取 id 再分析,程序如下:

memset(buff,0x0,buff_size);
if (recv(sock,buff,sizeof(buff),0) == SOCKET_ERROR){
id = WSAGetLastError();
switch (id)
{
case WSANOTINITIALISED: printf("not initialized\n"); break;
case WSASYSNOTREADY: printf("sub sys not ready\n"); break;
case WSAHOST_NOT_FOUND: printf("name server not found\n"); break;
case WSATRY_AGAIN: printf("server fail\n"); break;
case WSANO_RECOVERY: printf("no recovery\n"); break;
case WSAEINPROGRESS: printf("socket blocked by other prog\n"); break;
case WSANO_DATA: printf("no data record\n"); break;
case WSAEINTR: printf("blocking call canciled\n"); break;
case WSAEPROCLIM: printf("limit exceeded\n");
case WSAEFAULT: printf("lpWSAData in startup not valid\n");
default: printf("unknown error id = %d\n",id); break;
};
printf("receive error.\n");
};

热心网友 时间:2024-10-24 06:14

SOCKET ERROR

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com