Replace gethostbyname for IPv6 addresses

I have a program that uses gethostbyname (on Windows) to convert an IP address to a host name.

But it only works for IPv4 ...

What is the correct replacement for IPv6?

Thanks.

+4
source share
2 answers

A search for gethostbyname on MSDN tells us that it is outdated, and we should look at getaddrinfo , which has all the features to work with other addressed families.

Or, if you make an address to name the translation, you will get into getnameinfo

+6
source

Use getaddrinfo , which devalues ​​the old gethostbyname function.

+6
source

Source: https://habr.com/ru/post/1306345/


All Articles