From owner-freebsd-hackers@FreeBSD.ORG Thu May 22 18:47:49 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F22AC106566B for ; Thu, 22 May 2008 18:47:49 +0000 (UTC) (envelope-from ticso@cicely7.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.freebsd.org (Postfix) with ESMTP id 7A79C8FC0A for ; Thu, 22 May 2008 18:47:49 +0000 (UTC) (envelope-from ticso@cicely7.cicely.de) Received: from cicely5.cicely.de ([10.1.1.7]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id m4MIOH0o084833 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 22 May 2008 20:24:18 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (cicely7.cicely.de [10.1.1.9]) by cicely5.cicely.de (8.14.2/8.14.2) with ESMTP id m4MIOEBZ060022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 22 May 2008 20:24:15 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (localhost [127.0.0.1]) by cicely7.cicely.de (8.14.2/8.14.2) with ESMTP id m4MIOBhD055717; Thu, 22 May 2008 20:24:11 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: (from ticso@localhost) by cicely7.cicely.de (8.14.2/8.14.2/Submit) id m4MIOB6X055716; Thu, 22 May 2008 20:24:11 +0200 (CEST) (envelope-from ticso) Date: Thu, 22 May 2008 20:24:11 +0200 From: Bernd Walter To: "Bjoern A. Zeeb" Message-ID: <20080522182410.GB55002@cicely7.cicely.de> References: <839372.78392.qm@web46311.mail.sp1.yahoo.com> <20080522161214.Y47338@maildrop.int.zabbadoz.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080522161214.Y47338@maildrop.int.zabbadoz.net> X-Operating-System: FreeBSD cicely7.cicely.de 7.0-STABLE i386 User-Agent: Mutt/1.5.11 X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED=-1.8, BAYES_00=-2.599 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on cicely12.cicely.de Cc: freebsd-hackers@freebsd.org, John Timony Subject: Re: How can I translate IP to hostname in C X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 May 2008 18:47:50 -0000 On Thu, May 22, 2008 at 04:14:46PM +0000, Bjoern A. Zeeb wrote: > On Thu, 22 May 2008, John Timony wrote: > > Hi, > > >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()? > > See also http://www.unixguide.net/network/socketfaq/2.24.shtml for > further inspiration on this but slightly different topic. You can also use the newer getaddrinfo(3)/freeaddrinfo(3). I think it is bit easier to use and can it transparently handle inet6 addresses as well. The only downside is that some rare old systems don't support it. On FreeBSD it is suppoorted since FreeBSD-4, but some commerical OS implemented it later. -- B.Walter http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.