#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
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);
}