3 #include <sys/socket.h>
7 #include <pthr_pseudothread.h>
8 #include <pthr_iolib.h>
9 #include <pthr_server.h>
11 static void start_processor (int sock, void *data);
12 static void run (void *);
14 typedef struct processor_thread
16 pseudothread pth; /* Pseudothread handle. */
17 int sock; /* Socket. */
21 main (int argc, char *argv[])
23 /* Start up the server. */
24 pthr_server_main_loop (argc, argv, start_processor);
30 start_processor (int sock, void *data)
36 p = pmalloc (pool, sizeof *p);
39 p->pth = new_pseudothread (pool, run, p, "processor thread");
47 processor_thread p = (processor_thread) vp;
51 io = io_fdopen (p->pth, p->sock);
53 /* Sit in a loop reading strings and echoing them back. */
54 while (io_fgets (buffer, sizeof buffer, io, 1))
55 io_fputs (buffer, io);