Date: Tue, 3 Sep 2002 11:18:15 +1000 From: Edwin Groothuis <edwin@mavetju.org> To: Tony <tony@idk.com> Cc: freebsd-questions@freebsd.org Subject: Re: Need help: gethostbyaddr Message-ID: <20020903011815.GY785@k7.mavetju> In-Reply-To: <200209030021.RAA19794@idk.com> References: <200209030021.RAA19794@idk.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 02, 2002 at 05:21:50PM -0700, Tony wrote: > I just cannot seem to understand the function gethostbyaddr, more what and > how would one lookup an ip number. > > All I want to do it write a program to look up one ip number to it's host > name. I am very confused with this function. > > Example? #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> int main(void) { struct hostent *h; struct in_addr in; inet_aton("212.204.230.141",&in); h=gethostbyaddr((char *)&in,4,AF_INET); printf("%s is %s\n",inet_ntoa(in),h->h_name); return 0; } Edwin -- Edwin Groothuis | Personal website: http://www.MavEtJu.org edwin@mavetju.org | Weblog: http://www.mavetju.org/weblog/weblog.php bash$ :(){ :|:&};: | Interested in MUDs? http://www.FatalDimensions.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020903011815.GY785>