相关疑难解决方法(0)

gethostbyname 说没有这样的服务是已知的。在指定的命名空间中找不到该服务

Windows 中的这段简单代码会导致gethostbyname.

#include <stdio.h>
#include <winsock.h>
int main()
{
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2, 2), &wsaData);
    hostent* he = gethostbyname("www.stackoverflow.com");
    char* ip = inet_ntoa(*(struct in_addr*)he->h_addr_list[0]);
    printf(ip);
}
Run Code Online (Sandbox Code Playgroud)

它说:

onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(550)\nlansp_c.dll!00007FFCFC1FC759: (caller: 00007FFD2856388E) LogHr(1) tid(6e14) 8007277C No such service is known. The service cannot be found in the specified name space.
Run Code Online (Sandbox Code Playgroud)

我在 Windows 上。使用 Visual Studio 2019。我怎么能忽略它呢?目前,我正在调试,因为我的日志完全充满了此消息,所以很难找到所需的日志。

c++ winsock winsock2 windows-11

10
推荐指数
1
解决办法
6906
查看次数

标签 统计

c++ ×1

windows-11 ×1

winsock ×1

winsock2 ×1