1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
77 views6 pages
Slides Pratica Named Pipes e Select
1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
If you get a SIGPIPE sgna, ths means that you are tryng to read/wrte from a cosed ppe
A named ppe s a connecton between two processes. A
process bocks unt the other party open the ppe...
Beng t for readng or wrtng.
Its possbe to bypass ths behavor (open t non-bockng
- O_NONBLOCK), but be very, very carefu: f not propery programmed, t can ead to busy watng. If a named ppe s open non-bockng, EOF s ndcated when read() returns 0.
When desgnng a cent/server mutpe cent appcaton,
ths means that ether the ppe s re-opened after each cent dsconnects, or the ppe s open read-wrte.
If opened "read-wrte", the server w not bock unt the
other party connects (snce, he tsef s aso another party!)
9 select()
Carefu: n s the number of the hghest fe
descrptor added of one.
Its not the number of fe descrptors
fd_set A bt set representng fe descrptors
FD_ZERO(fd_set* set) Ceans up the fe descrptor set
FD_SET(nt fd, fd_set* set)
Sets a bt n the fe descrptor set
FD_CLEAR(nt fd, fd_set* set)
Cears a bt n the fe descrptor set
FD_ISSET(nt fd, fd_set* set)
Tests f a fe descrptor s set 10 Example (printerd.c) {...) #de11he BbF_STZE 4096 #de11he hbh_PRThTERS 3 cohs1 chaJ* PRThTER_hAhE|] = { "pJ1h1eJ1", "pJ1h1eJ2", "pJ1h1eJ3" }, // The pJ1h1eJ 11e descJ1p1oJs 1h1 pJ1h1eJ|hbh_PRThTERS], vo1d cJea1e_pJ1h1eJs{) { 1oJ {1h1 1=0, 1<hbh_PRThTERS, 1++) { uh1hk{PRThTER_hAhE|1]), mk111o{PRThTER_hAhE|1], 0_CREAT]0_EXCL]0666), pJ1h1eJ|1] = opeh{PRThTER_hAhE|1], 0_R00hLY]0_h0hBL0CK), asseJ1{pJ1h1eJ|1] >= 0), } } 1h1 ma1h{1h1 aJgc, chaJ* aJgv|]) { cJea1e_pJ1h1eJs{), accep1_Jeques1s{), }