WSAESOCKTNOSUPPORT (10044 不支援的socket 型别目前使用的WinSock 版本不支援函式所指定的socket 型别 17、。举例来说,完全根据WinSock 1.1版的规格书发展的WinSock 协定核心,并不支援SOCK_RAW这个socket 型别。在呼叫socket(函式时,位址家族选AF_INET( PF_INET 而socket 型别选SOCK_RAW的话,就会发生这个错误。
int rawsock; char buff[BUFFSIZE]; int n; int count = 0; rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_TCP); // rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP); // rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP); // rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_RAW); if(rawsock ...
MessageBox(_T("套接字初始化失败!")+str); } 4、声明套接字 sRaw = ::socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); 5、设置套接字选项(这里是不需要自己设置ip的简单icmp程序) intnTime =1000;intret = ::setsockopt(sRaw, SOL_SOCKET, SO_RCVTIMEO, (char*)&nTime,sizeof(nTime)); 6、设置发...
使用socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)创建原始套接字。示例代码如下: int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if (sockfd < 0) { perror("socket creation failed"); exit(EXIT_FAILURE); } 1. 2. 3. 4. 5. 为什么普通的TCP/UDP Socket无法直接处理ICMP消息? 普通的TCP/U...
create_socket(socket.AF_INET, socket.SOCK_RAW, ICMP_CODE) create_socket(socket.AF_INET, socket.SOCK_RAW, ICMP_CODE)
若是你真的有心去测试的话,程式中故意如此呼唤socket():hSock=socket(AF_INET, SOCK_STREAM, IPPROTO_UDP);你会发觉,如此的socket()函式呼唤会取得WSAEPROTONOSUPPORT错误。这显然不对,照理应该取得WSAEPROTOTYPE那个错误才对。 WSAEPROTOTYPE那个错误表示指定了错误的协定,而所指定的协定是该位址家族(协定家族)所...
// rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP); // rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_RAW); if(rawsock < 0){ printf("raw socket error!\n"); exit(1); } while(1){ n = recvfrom(rawsock,buff,BUFFSIZE,0,NULL,NULL); ...
// rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP); // rawsock = socket(AF_INET,SOCK_RAW,IPPROTO_RAW); if(rawsock < 0){ printf("raw socket error!\n"); exit(1); } while(1){ n =recvfrom(rawsock,buff,BUFFSIZE,0,NULL,NULL); ...
m_hSocket = WSASocket (AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, WSA_FLAG_OVERLAPPED); if (m_hSocket == INVALID_SOCKET) { printf("socket创建失败!"); } int bread = setsockopt(m_hSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)); ...
sockRaw = WSASocket(AF_INET,SOCK_RAW,IPPROTO_ICMP ,NULL, 0,WSA_FLAG_OVERLAPPED); //注:为了使用发送接收超时设置(即设置SO_RCVTIMEO, SO_SNDTIMEO), // 必须将标志位设为WSA_FLAG_OVERLAPPED ! // 创建原始套接字不成功 if (sockRaw == INV ALID_SOCKET) { ...