From owner-freebsd-hackers@FreeBSD.ORG Thu May 22 18:31:25 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 7F10B106566C for ; Thu, 22 May 2008 18:31:25 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.bluestop.org (unknown [IPv6:2001:41c8:1:548a::2]) by mx1.freebsd.org (Postfix) with ESMTP id 1EC398FC14 for ; Thu, 22 May 2008 18:31:25 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from [IPv6:2a01:348:10f:0:c179:988f:8401:ad08] (unknown [IPv6:2a01:348:10f:0:c179:988f:8401:ad08]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by muon.bluestop.org (Postfix) with ESMTP id D0CDA30120; Thu, 22 May 2008 19:31:23 +0100 (BST) Message-ID: <4835BBD5.1050003@cran.org.uk> Date: Thu, 22 May 2008 19:30:45 +0100 From: Bruce Cran User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: John Timony References: <839372.78392.qm@web46311.mail.sp1.yahoo.com> In-Reply-To: <839372.78392.qm@web46311.mail.sp1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org 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 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:31:25 -0000 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