C++ Resolve a host IP address from a URL
问题 How can I resolve a host IP address, given a URL in Visual C++? 回答1: To use the socket functions under Windows, you have to start by calling WSAStartup , specifying the version of Winsock you want (for your purposes, 1.1 will work fine). Then you can call gethostbyname to get the address of the host. When you're done, you're supposed to call WSACleanup. Putting that all together, you get something like this: #include <windows.h> #include <winsock.h> #include <iostream> #include <iterator>