Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rdemeter
GitHub Repository: rdemeter/so
Path: blob/master/lab5/fifoserver.c
221 views
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <sys/stat.h>
5
#include <unistd.h>
6
#include <linux/stat.h>
7
8
#define FIFO_FILE "myfifo"
9
#define SZBUF 80
10
#define QUIT "bye"
11
12
int main(void)
13
{
14
FILE* fp;
15
char readbuf[SZBUF];
16
17
/*create the fifo*/
18
umask(0);
19
mknod(FIFO_FILE, S_IFIFO|0666, 0);
20
21
printf("Running server... To quit, send via the client the msg 'bye'.\n");
22
23
while(1) {
24
fp = fopen(FIFO_FILE,"r");
25
fgets(readbuf, SZBUF, fp);
26
27
if (!strcmp(readbuf,QUIT)) break;
28
29
printf("Received string: %s\n",readbuf);
30
fclose(fp);
31
}
32
return 0;
33
}
34
35