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。我怎么能忽略它呢?目前,我正在调试,因为我的日志完全充满了此消息,所以很难找到所需的日志。