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="freebsd.org";
int port=80;
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
sin.sin_addr.s_addr = inet_addr(hstname);
if(sin.sin_addr.s_addr == INADDR_NONE) {
he = gethostbyname(hstname);
if(!he) {
close(s);
errno=0;
return -1;
}
memcpy(&sin.sin_addr, he->h_addr, he->h_length);
}
Jacob Rhoden Phone: +61 3 9844 6102
ITS Division Email: [EMAIL PROTECTED]
Melbourne University Mobile: +61 403 788 386
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message