FIFO problems

Tobias Pfeiffer BoteDesSchattens at
Thu Sep 11 07:23:37 CEST 2003


I want to write a "client-server-application" (only running on the same 
machine) or actually I've already begun with and have problems with the 
interprocess communication. The server, when started, opens a FIFO and 
opens it with open(infifo, 'r'). Then I check the content of the file 

while 1:
    	line = serverIn.readline()[:-1]
    	if line == "bla":
    	    	do this
    	    	print line

So at the beginning everything works fine. I can start the client prog 
and they will talk and understand to each other. The same if I connect 
with three or more clients simultaneously (?). If one of these clients 
exists, no problem. But when the last process exists and closes the 
FIFO-file which was opened by, os.O_WRONLY), the server 
begins to print an empty string everytime it goes through the loop, 
means it won't wait for a complete line to appear before continuing. 
Then I modified the thing above to:

while 1:
    	line = serverIn.readline()[:-1]
    	if line == "bla":
    	    	do this
    	elif line == "":
    	    	open(infifo, 'r')
    	    	print "help!!!"
    	    	print line

So in contrast to what I thought, there was not a bunch of "help!!!" 
lines printed, but nothing. When I tried then to connect again, there 
was a single "help!!!" and then the correct message for the client 
having connected.

So, anyone any idea how I can fix this. I just want the server to 
continue line-by-line-reading...


More information about the Python-list mailing list