Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 979
Roland Mainz Avatar asked Dec 21 '25 14:12

Roland Mainz


1 Answers

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?

like image 132
Torrecto - MSFT Avatar answered Dec 24 '25 11:12

Torrecto - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!