diff --git a/src/server.c b/src/server.c index b7801ee..f749b04 100644 --- a/src/server.c +++ b/src/server.c @@ -168,6 +168,20 @@ void *ClientListener(void *arg) { /* Thread, sends messages to the client */ void *ClientSender(void *arg) { struct client_details details = *((struct client_details*) arg); + char buf[BUF_LEN]; + int n = 0; + + while (1) { + while ((n = read(details.pipe[0], buf, BUF_LEN)) > 0) { + write(details.sockid, buf, n); + } + if (n < 0) { + fprintf(stderr, "ERROR: read\n"); + sprintf(buf, "ERROR: read\n"); + write(details.sockid, buf, strlen(buf + 1)); + break; + } + } pthread_exit(0); }