C++ Windows function call that get local hostname and IP address
问题 Is there built-in windows C++ function call that can get hostname and IP address? Thanks. 回答1: To get the hostname you can use: gethostname or the async method WSAAsyncGetHostByName To get the address info, you can use: getaddrinfo or the unicode version GetAddrInfoW You can get more information about the computer name like the domain by using the Win32 API: GetComputerNameEx. 回答2: Here is a multiplatform solution... Windows, Linux and MacOSX. You can obtain ip address, port, sockaddr_in,