How can I translate IP to hostname in C

Bruce Cran bruce at cran.org.uk
Thu May 22 18:31:25 UTC 2008


John Timony wrote:
> Hi,guys
> 
> 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 could use gethostbyaddr(3), but those traditional functions have 
been replaced with more flexible versions such as getnameinfo(3) on 
newer systems.  There's a good introduction to modern sockets 
programming at http://people.redhat.com/drepper/userapi-ipv6.html

-- 
Bruce Cran


More information about the freebsd-hackers mailing list