Completata la parte su getaddinfo con delle funzioni di ausilio per chiamare
[gapil.git] / listati / TCP_echod_third.c
diff --git a/listati/TCP_echod_third.c b/listati/TCP_echod_third.c
new file mode 100644 (file)
index 0000000..c150ad4
--- /dev/null
@@ -0,0 +1,20 @@
+int main(int argc, char *argv[])
+{
+/* 
+ * Variables definition  
+ */
+    int list_fd, conn_fd;
+    ...
+    /* Main code begin here */
+    if (compat) {                             /* install signal handler */
+       Signal(SIGCHLD, HandSigCHLD);         /* non restarting handler */
+    } else {
+       SignalRestart(SIGCHLD, HandSigCHLD);  /* restarting handler */
+    }
+    /* create and bind socket */
+    if ( (list_fd = sockbind(argv[optind], "echo", 6, SOCK_STREAM)) < 0) {
+       if (errno) perror("Socket creation error");
+       return 1;
+    }   
+    ...
+}