How can I translate IP to hostname in C

Oliver Fromme olli at lurza.secnetix.de
Fri May 23 06:58:59 UTC 2008


Bjoern A. Zeeb wrote:
 > John Timony wrote:
 > > I am writing a c program in FreeBSD,and I can not
 > > translate a ip to hostname
 > > ,i wonder if there is a function to take this job...
 > 
 > You mean like gethostbyaddr()?

gethostbyaddr() is considered obsolete, I think.
You should use getaddrinfo() instead, which is more
flexible and easier to use, and it enables you to
easily write code that is independent and agnostic
of the address family (IPv4 vs. IPv6 vs. others).
The manual page contains detailed example code.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"The most important decision in [programming] language design
concerns what is to be left out."  --  Niklaus Wirth


More information about the freebsd-hackers mailing list