From owner-freebsd-questions Mon Sep 2 18:18:28 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 88D4137B400 for ; Mon, 2 Sep 2002 18:18:24 -0700 (PDT) Received: from topaz.mdcc.cx (topaz.mdcc.cx [212.204.230.141]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04D1043E3B for ; Mon, 2 Sep 2002 18:18:24 -0700 (PDT) (envelope-from edwin@mavetju.org) Received: from k7.mavetju (topaz.mdcc.cx [212.204.230.141]) by topaz.mdcc.cx (Postfix) with ESMTP id 78C5A2B91B; Tue, 3 Sep 2002 03:18:21 +0200 (CEST) Received: by k7.mavetju (Postfix, from userid 1001) id 7601B6A7124; Tue, 3 Sep 2002 11:18:15 +1000 (EST) Date: Tue, 3 Sep 2002 11:18:15 +1000 From: Edwin Groothuis To: Tony Cc: freebsd-questions@freebsd.org Subject: Re: Need help: gethostbyaddr Message-ID: <20020903011815.GY785@k7.mavetju> Mail-Followup-To: Edwin Groothuis , Tony , freebsd-questions@freebsd.org References: <200209030021.RAA19794@idk.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200209030021.RAA19794@idk.com> User-Agent: Mutt/1.4i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include #include #include #include #include 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