سؤال

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