标签:its eof end http family table ast 为什么 .lib
bind处一直报错WSAEADDRNOTAVAIL10049,不知道为什么?
|
|
#include <stdio.h> #include <winsock2.h> #include <ws2ipdef.h> #pragma comment(lib, "ws2_32.lib") #define BUF_SIZE 30 int main() { int iResult = 0; WSADATA wsaData; SOCKET sock; char message[BUF_SIZE]; int strlen; int addrsize; SOCKADDR_IN6 addrto, addrfrom; iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); sock = socket(AF_INET6, SOCK_RAW, 89); /*需要管理员权限*/ if (sock == INVALID_SOCKET) printf("sock err = %d\n", WSAGetLastError()); addrto.sin6_family = AF_INET6; addrto.sin6_addr.u.Byte[0] = 0xfc; addrto.sin6_addr.u.Byte[1] = 0x00; addrto.sin6_addr.u.Byte[2] = 0x00; addrto.sin6_addr.u.Byte[3] = 0x00; addrto.sin6_addr.u.Byte[4] = 0x00; addrto.sin6_addr.u.Byte[5] = 0x00; addrto.sin6_addr.u.Byte[6] = 0x0d; addrto.sin6_addr.u.Byte[7] = 0x41; addrto.sin6_addr.u.Byte[8] = 0x00; addrto.sin6_addr.u.Byte[9] = 0x00; addrto.sin6_addr.u.Byte[10] = 0x00; addrto.sin6_addr.u.Byte[11] = 0x00; addrto.sin6_addr.u.Byte[12] = 0x0d; addrto.sin6_addr.u.Byte[13] = 0x41; addrto.sin6_addr.u.Byte[14] = 0x00; addrto.sin6_addr.u.Byte[15] = 0x02; addrto.sin6_port = 89; iResult = bind(sock, (SOCKADDR *)&addrto, sizeof(SOCKADDR_IN6)); if (iResult == SOCKET_ERROR) printf("bind err = %d\n", WSAGetLastError()); while (1) { addrsize = sizeof(addrfrom); strlen = recvfrom(sock, message, BUF_SIZE, 0, (SOCKADDR*)&addrfrom, &addrsize); } }
标签:its eof end http family table ast 为什么 .lib
原文地址:https://www.cnblogs.com/yanhc/p/10306304.html