Date: Fri, 20 Sep 2002 16:42:33 +1000 From: Jacob Rhoden <jrhoden@unimelb.edu.au> To: Tony <tony@idk.com>, freebsd-questions@freebsd.org Subject: Re: gethostbyname Message-ID: <200209201642.33375.jrhoden@unimelb.edu.au> In-Reply-To: <200209200618.XAA05767@idk.com> References: <200209200618.XAA05767@idk.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209201642.33375.jrhoden>