From owner-freebsd-questions Thu Sep 19 23:42:36 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 B373637B401 for ; Thu, 19 Sep 2002 23:42:35 -0700 (PDT) Received: from ariel.ucs.unimelb.edu.au (ariel.ucs.unimelb.edu.au [128.250.20.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id D89DA43E3B for ; Thu, 19 Sep 2002 23:42:34 -0700 (PDT) (envelope-from jrhoden@unimelb.edu.au) Received: from elkanah.its.unimelb.edu.au (elkanah.its.unimelb.edu.au [128.250.18.41]) by ariel.ucs.unimelb.edu.au (8.12.3/8.12.3) with ESMTP id g8K6gXiB014329; Fri, 20 Sep 2002 16:42:33 +1000 (EST) Content-Type: text/plain; charset="iso-8859-1" From: Jacob Rhoden Organization: University of Melbourne To: Tony , freebsd-questions@freebsd.org Subject: Re: gethostbyname Date: Fri, 20 Sep 2002 16:42:33 +1000 X-Mailer: KMail [version 1.4] References: <200209200618.XAA05767@idk.com> In-Reply-To: <200209200618.XAA05767@idk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200209201642.33375.jrhoden@unimelb.edu.au> 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 Fri, 20 Sep 2002 16:18, Tony wrote: > Anyone have a simple example of how to use this function.. Hope this helps. struct hostent *he; struct sockaddr_in sin; char *hostname=3D"freebsd.org"; int port=3D80; sin.sin_family =3D AF_INET; sin.sin_port =3D htons(port); sin.sin_addr.s_addr =3D inet_addr(hstname); if(sin.sin_addr.s_addr =3D=3D INADDR_NONE) { he =3D gethostbyname(hstname); if(!he) { close(s); errno=3D0; return -1; } memcpy(&sin.sin_addr, he->h_addr, he->h_length); } =20 Jacob Rhoden Phone: +61 3 9844 6102 ITS Division Email: jrhoden@unimelb.edu.au Melbourne University Mobile: +61 403 788 386 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message