From 28f540f45bbacd939bfd07f213bcad2bf730b1bf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 Feb 1995 01:27:10 +0000 Subject: initial import --- manual/examples/isockad.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 manual/examples/isockad.c (limited to 'manual/examples/isockad.c') diff --git a/manual/examples/isockad.c b/manual/examples/isockad.c new file mode 100644 index 0000000000..54ec1cca4c --- /dev/null +++ b/manual/examples/isockad.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +void +init_sockaddr (struct sockaddr_in *name, + const char *hostname, + unsigned short int port) +{ + struct hostent *hostinfo; + + name->sin_family = AF_INET; + name->sin_port = htons (port); + hostinfo = gethostbyname (hostname); + if (hostinfo == NULL) + { + fprintf (stderr, "Unknown host %s.\n", hostname); + exit (EXIT_FAILURE); + } + name->sin_addr = *(struct in_addr *) hostinfo->h_addr; +} -- cgit v1.2.3