Initial revision
authorroland <roland>
Mon, 9 Nov 1992 23:56:37 +0000 (23:56 +0000)
committerroland <roland>
Mon, 9 Nov 1992 23:56:37 +0000 (23:56 +0000)
manual/examples/isockad.c [new file with mode: 0644]

diff --git a/manual/examples/isockad.c b/manual/examples/isockad.c
new file mode 100644 (file)
index 0000000..d5e289b
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+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 (SERVERHOST);
+  if (!hostinfo) 
+    {
+      fprintf (stderr, "Unknown host %s.\n", hostname);
+      exit (EXIT_FAILURE);
+    }
+  name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
+}