Win32 getaddrinfo() not using C:\Windows\System32\drivers\etc\hosts?

154 Views Asked by At

Does Win32 getaddrinfo() use C:\Windows\System32\drivers\etc\hosts?

We want to use C:\Windows\System32\drivers\etc\hosts to specify IPv6-only addresses (which are NOT part of the DNS), and let our Win32 console application use it via getaddrinfo(), but it does not find it.

Why? Is there maybe an API which uses C:\Windows\System32\drivers\etc\hosts AND DNS?

1

There are 1 best solutions below

0
Torrecto - MSFT On

No.

C:\Windows\System32\drivers\etc\hosts is a DNS file, which can be opened directly with Notepad and redirects the IP address.

    The format is: IP address - space - domain name
    It can redirect a domain name to an IP.

Does Win32 getaddrinfo() use C:\Windows\System32\drivers\etc\hosts?

The getaddrinfo function provides protocol-independent translation from an ANSI host name to an address.

If you want to specify IPv6-only addresses, you can see my answer How to display current IPv6 connections?