rkellerm
rkellerm

Reputation: 5522

gethostbyname replacement for IPv6 addresses

I have a program that uses gethostbyname (in Windows) in order to convert IP address to hostname.

But, it works only for IPv4...

What is the correct replacement for IPv6?

Thanks.

Upvotes: 7

Views: 12828

Answers (2)

Marcelo Cantos
Marcelo Cantos

Reputation: 186118

Use getaddrinfo, which deprecates the old gethostbyname function.

Upvotes: 7

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239824

Looking up gethostbyname in MSDN tells us that it's deprecated and we should look at getaddrinfo, which has all kinds of options for dealing with other addressing families.

Or if you're doing address to name translation, you'll end up at getnameinfo

Upvotes: 10

Related Questions