I am writing two different terminal programs that will communicate with each other via named pipes. The client will have to read from two input sources: stdin and its read fifo, and likewise for the server.

The problem that I am having is that the client and the server seem to be blocked so although I type in the terminal, nothing gets sent.

What is the correct way to setup the fifos. And by setup I mean in what order should they be opened/closed. Thanks

For example, I am doing the following in the client:

//Open client's read fifo  (O_RDWR)

 while ( select(maxfd, &temp_readset, NULL, NULL, NULL) > 0) 
      if ( FD_ISSET(fileno(stdin), &temp_readset) )
         //Read from std input

         //Open client's write fifo to send data to server

     if(FD_ISSET(client_receive_fifo, &temp_readset )
       //Open client's read fifo

       // Do stuff with data received from the server
       //Close client's read fifo     

    temp_readset = original_readset;