質問

I want to use getaddrinfo() but get only the first result.

more specifically, I want the function to first scan the hosts file and fetch the first result found, and only if not found in hosts I want to query the dns server.

is it possible?

thanks.

役に立ちましたか?

解決 2

The order on how resolving hosts is done is define in /etc/host.conf using the keyword order:

order

This keyword specifies how host lookups are to be performed. It should be followed by one or more lookup methods, separated by commas. Valid methods are bind, hosts, and nis.

However I doubt you can restrict the number of results to 1 per this configuration directly.

他のヒント

You can't. It behaves as documented. You only have to use one result: that's up to you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top