FIFO Server Program

enter image description here

In the above program, I typed linux. Basically, it should connect the client and server to separate terminals. But when I run them in the correct order, i.e.

  • Compile server -> start server
  • Compile client -> start client

Terminals just do nothing. It does not even print the "Trying to connect" first printf statement. What is the mistake here?

EDIT

I checked for mkfifo return value as @parapura rajkumar said. But still remains the same. Here is my modified server code.

 if(mkfifo("fifo1",0666)<0) { printf("Error"); } if(mkfifo("fifo2",0666)<0) { printf("Error"); } fflush(stdout); 
0
source share
1 answer

You are at an impasse. The server is waiting for opening ("fifo1", O_RDONLY), and the client is waiting for opening ("fifo2", O_RDONLY).

Edit client.c:

 int writefd = open("fifo1",O_WRONLY); int readfd = open("fifo2",O_RDONLY); 
+2
source

Source: https://habr.com/ru/post/904357/


All Articles