Need to have non-blocking named pipes capable of two way communication in c on Linux
I want to create one server and one client(two separate programs) where in server creates two named pipes(i guess thats the minimum required for bidirectional flow of traffic) and then the client is started,and Client and server should be able to send and recie开发者_如何学JAVAve data both ways all the time(full duplex types).I think that would require me to have non-blocking named pipes.Would like some help as i have been able to create half duplex type of communication but struggling to make a contineous seamless transfer of data between client and server happen.
Thanks
Possible options:
Local domain sockets: AF_LOCAL family with SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET type. The socket can be "in-memory", meaning you connect to it using a unique string, or it can be a socket file in the filesystem. It works just like any network socket, full-duplex.
Two pipes: one for reading, one for writing (vice versa for the other process). Might be a bit more complicated keeping track of two pipes, as opposed to the local domain socket.
Helpful link Check out the part on Pipes and the one on Unix Sockets.
Have you considered using select()
to handle the reading named pipe?
精彩评论