0

我已经定义了一个 UDP 套接字

#include<iostream>
#include<WinSock2.h> 
sockaddr_in faraddr; 
        memset(&faraddr, 0, sizeof(sockaddr_in));
        unsigned short Port = 6789;
        faraddr.sin_family      = AF_INET;
        faraddr.sin_port        = htons(Port);
        faraddr.sin_addr.s_addr = inet_addr(Loopbackaddress);
        SOCKET XmitSocket;
        XmitSocket = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP);
          if (XmitSocket < 0)
          {
              printf("Socket Creation Failed\n");
          }
    int nBuffersize = 1024 * 1024;
    uint8 nOptVal = 255;
  setsockopt(XmitSocket,IPPROTO_IP,IP_TTL, (const char*)&nOptVal, 1); 

// 标识符 IP_TTL 未定义

    setsockopt(XmitSocket,SOL_SOCKET,SO_SNDBUF, (const char*)&nBuffersize, 4);

    int prio = 6 << 5;//First 3 bits of TOS field
    setsockopt(XmitSocket, SOL_IP, IP_TOS, &prio, sizeof(prio));

// 标识符 SOL_IP 和 IP_TOS 未定义

我收到编译错误我是否缺少一些 HeaderFile

4

1 回答 1

0
#include <Ws2tcpip.h>

您似乎错过了一些头文件。有关详细信息,请参阅MSDN

于 2013-07-09T11:41:06.303 回答