资源:
WSADATA WSAData;
SOCKET sock;
if (WSAStartup(MAKEWORD(2,2), &WSAData)!=0) {
printf("\nProblem with WSAStartup\n\n");
return FALSE;
}
if ((sock = WSASocket(AF_INET,SOCK_RAW,IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET) {
WSACleanup();
printf("\nProblem with WSASocket\n\n");
return FALSE;
}
int flag = 1;
if (setsockopt(sock,IPPROTO_IP, IP_HDRINCL,(char *)&flag,sizeof(flag)) == SOCKET_ERROR) {
printf("getsockopt failed with error: %u\n\n", WSAGetLastError());
closesocket(sock);
WSACleanup();
return FALSE;
}
每次我在我的程序中运行它时,我都会得到:
getsockopt failed with error: 10049
10049 是 WSAEADDRNOTAVAIL 的错误代码,意思是“请求的地址在其上下文中无效”。
请帮忙,我不知道为什么我不断收到这个错误。