http://qs1969.pair.com?node_id=121130

Mirage has asked for the wisdom of the Perl Monks concerning the following question:

Hi there! i am trying to build a server, with multiple processes, for each client a child. So far everything works fine, but as these processes have to communicate i searched and found that FIFOs may be useful for that. So i used them and its working, but somehow it isnt.. the problem is the data from the client isnt received somehow. Below is the code for it, maybe someone can tell me why the data from the client isnt printed out by the parent (just testing for now) Thanks for help Code:
#!/usr/bin/perl -w use strict; use IO::Socket; $| = 1; #get the port to bind to or default to 8000 my $port = $ARGV[0] || 8000; #ignore child processes to prevent zombies $SIG{CHLD} = 'IGNORE'; #create the listen socket my $listen_socket = IO::Socket::INET->new(LocalPort => $port, Listen => 10, Proto => 'tcp', Type => SOCK_STREAM, Reuse => 1); #make sure we are bound to the port die "Cant't create a listening socket:\n$@" unless $listen_socket; warn "Server ready. Waiting for connections ... \n"; if(!-e "$ENV{HOME}/.fifopipe"){system 'mkfifo ~/.fifopipe' || system ' +mknod ~/.fifopipe p' || die $@;} #wait for connections at the accept call while (my $connection = $listen_socket->accept) { my ($pid, $line); # perform the fork or exit if ($pid = fork) { #i'm the parent! #who connected? warn localtime(time)." Connection recieved ... ",$connection-> +peerhost,"\n"; #close the connection, the parent has already passed it off to a c +hild. $connection->close(); open(FIFO, "< $ENV{HOME}/.fifopipe") or die $@; while(<FIFO>){$_ =~ s/a-z/A-Z/i;print $_;} close(FIFO); } else { #i'm the child! #die in case of forking not possible die "Error while forking: $@" unless defined $pid; #close the child's listen socket, we dont need it. $listen_socket->close; open(FIFO, "> $ENV{HOME}/.fifopipe") or die $@; while(<$connection>){print FIFO $_;}; # print FIFO "mouh\n"; close(FIFO); #if the child returns, then just exit; exit; } #go back and listen for the next connection! }