简体   繁体   English

如何解决此winsock错误?

[英]How to solve this winsock error?

C:\Users\Chan\Desktop\test - fail\winsock2 socket server.cpp: In function `int _tmain()':
C:\Users\Chan\Desktop\test - fail\winsock2 socket server.cpp:48: error: `getaddrinfo' was not declared in this scope
C:\Users\Chan\Desktop\test - fail\winsock2 socket server.cpp:59: error: `freeaddrinfo' was not declared in this scope
C:\Users\Chan\Desktop\test - fail\winsock2 socket server.cpp:68: error: `freeaddrinfo' was not declared in this scope
C:\Users\Chan\Desktop\test - fail\winsock2 socket server.cpp:74: error: `freeaddrinfo' was not declared in this scope

Using this header files 使用此头文件

#include "winsock2.h"
#include "windows.h"
#include "WS2tcpip.h"

The header file WS2tcpip.h uses this define: 头文件WS2tcpip.h使用以下定义:

#if (_WIN32_WINNT >= 0x0600)

This means that in your build you should define _WIN32_WINNT to 0x600 (Vista) or higher. 这意味着在构建中,您应将_WIN32_WINNT定义为0x600(Vista)或更高版本。 This means that the API you want doesn't exist in WinXP. 这意味着WinXP中不存在所需的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM