Add reading from pipe and sending to stream for ClientSender
This commit is contained in:
parent
dd7beccdf8
commit
8841e351d0
1 changed files with 14 additions and 0 deletions
14
src/server.c
14
src/server.c
|
@ -168,6 +168,20 @@ void *ClientListener(void *arg) {
|
||||||
/* Thread, sends messages to the client */
|
/* Thread, sends messages to the client */
|
||||||
void *ClientSender(void *arg) {
|
void *ClientSender(void *arg) {
|
||||||
struct client_details details = *((struct client_details*) 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);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue