]> git.sesse.net Git - jam/commitdiff
Make the receiver worker actually handle the socket.
authorsgunderson@bigfoot.com <>
Wed, 31 Jan 2007 16:28:18 +0000 (17:28 +0100)
committersgunderson@bigfoot.com <>
Wed, 31 Jan 2007 16:28:18 +0000 (17:28 +0100)
jam.c

diff --git a/jam.c b/jam.c
index d22ced453ff2c4769b9a558f895c54c59d799960..b4f8ad37e4e7d3e014471cf4b53c7ab37ee1d7c6 100644 (file)
--- a/jam.c
+++ b/jam.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <pthread.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -7,7 +8,25 @@
 void *receiver_worker(void *arg)
 {
        int sock = (int)arg;
+       char buf[65536];
+
        printf("Received worker for socket %u\n", sock);
+
+       for ( ;; ) {
+               int ret = read(sock, buf, 65536);
+               if (ret == 0)
+                       break;
+
+               // FIXME: update stats here
+       }
+
+       printf("Socket %u done\n", sock);
+       
+       if (close(sock) == -1) {
+               perror("close()");
+               exit(1);
+       }
+
        pthread_exit(0);
 }