-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipc3clint.c
More file actions
44 lines (43 loc) · 907 Bytes
/
ipc3clint.c
File metadata and controls
44 lines (43 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#define BUF_LEN 256
int main()
{
int srvfd;
int clifd;
char txmsg[BUF_LEN];
char rxmsg[BUF_LEN];
int cnt;
srvfd=open("srvfifo",O_WRONLY);
if(!srvfd)
{
printf("error in opening server fifo\n");
return (1);
}
printf("Connected to server \n");
printf("Enter some message to send to server\n");
fgets(txmsg,BUF_LEN,stdin);
write(srvfd,txmsg,strlen(txmsg)+1);
printf("Sent given message to server \n");
clifd=open("clififo",0600);
if(clifd<0)
{
if(mkfifo("clififo",0600))
{
printf("Error in creating client FIFO\n");
return(1);
}
else
{
clifd=open("clififo",O_RDONLY);
printf("Create client FIFO\n");
}
}
printf("waiting for response message from server\n");
cnt=read(clifd,rxmsg,BUF_LEN);
puts(rxmsg);
close(srvfd);
close(clifd);
}