Getnameinfo windows




















I'm wondering what is wrong in my code to make each lookup take over 4 seconds? Creator of the Software Update Wizard If you create a Window and has a button click to run this lookup procedure, then you can run this lookup in another new thread to avoid it suspend the UI thread.

Thanks again. You are right - multi-threading appears to be the only option for me. That makes the total lookup time in a single thread over 16 minutes! Many thanks for taking the trouble to respond. On your suggestion I have dug a little deeper and captured the timings for around ip addresses from my Apache web log file. Nonzero error codes returned by the getnameinfo function also map to the set of errors outlined by Internet Engineering Task Force IETF recommendations.

The following table lists these error codes and their WSA equivalents. It is recommended that the WSA error codes be used, as they offer familiar and comprehensive error information for Winsock programmers. The getnameinfo function is the ANSI version of a function that provides protocol-independent name resolution. This function can be used to determine the host name for an IPv4 or IPv6 address, a reverse DNS lookup, or determine the service name for a port number.

The getnameinfo function can also be used to convert an IP address or a port number in a sockaddr structure to an ANSI string. This function can also be used to determine the IP address for a host name. Another name that can be used for the getnameinfo function is GetNameInfoA. Macros in the Ws2tcpip. To simplify determining buffer requirements for the host and serv parameters, the following values for maximum host name length and maximum service name are defined in the Ws2tcpip.

The flags parameter can be used to customize processing of the getnameinfo function. The following flags are available:. When no corresponding node name can be found, the buffer pointed to by node is instead set to the numeric form of the socket address in the socket address structure that sa points to. The service name found is stored in the buffer pointed to by the service parameter.

This buffer has a maximum size of servicelen characters. When service is a null pointer or servicelen is zero, no service name is returned. When no service name can be found, the buffer pointed to by service is instead set to the numeric form of the service address for example, its port number.

By default, getnameinfo returns the fully-qualified domain name of the host. Sebastian Dressler 7, 2 2 gold badges 32 32 silver badges 55 55 bronze badges. Thank you. But I think there is no reason to not use boost, so I think I will take a look. You are using the return value, assuming it holds the hostname, but this is not correct. I've made an edit to my answer addressing this issue. Add a comment. Active Oldest Votes. Improve this answer. Robert Siemer Robert Siemer Community Bot 1 1 1 silver badge.

Sebastian Dressler Sebastian Dressler 7, 2 2 gold badges 32 32 silver badges 55 55 bronze badges. If you're printing the informations of your host, i. Right, but as mentioned on the site you can also perform hostname lookups with getaddrinfo.



0コメント

  • 1000 / 1000