Completata la parte su getaddinfo con delle funzioni di ausilio per chiamare
[gapil.git] / listati / TCP_echo_fifth.c
diff --git a/listati/TCP_echo_fifth.c b/listati/TCP_echo_fifth.c
new file mode 100644 (file)
index 0000000..2f21902
--- /dev/null
@@ -0,0 +1,18 @@
+int main(int argc, char *argv[])
+{
+/* 
+ * Variables definition  
+ */
+    int sock, i;
+    int reset = 0;
+    ...
+    /* call sockaddr to get a connected socket */
+    if ( (sock = sockconn(argv[optind], "echo", 6, SOCK_STREAM)) < 0) {
+       if (errno) perror("Socket creation error");
+       return 1;
+    }
+    /* do read/write operations */
+    ClientEcho(stdin, sock);
+    /* normal exit */
+    return 0;
+}