Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: multiple processes

by Zaxo (Archbishop)
on Oct 25, 2001 at 09:47 UTC ( #121383=note: print w/replies, xml ) Need Help??


in reply to multiple processes

It looks like your FIFO is only used for the child to speak to the parent. Would a regular pipe serve better? It would be faster.

while (my $connection = $listen_socket->accept) { my ($pid, $line, $in, $out); pipe $in, $out or die $!; if ($pid = fork) { close($out); warn localtime(time), " Connection recieved ... ", $connection->peerhost, $/; $connection->close(); # microsleep till the kid's awake do { select undef, undef, undef,.001} until kill 0, $pid; + while(<$in>){$_ =~ s/a-z/A-Z/i;print $_;} close($in); } elsif (defined $pid){ close($in); $listen_socket->close; while(<$connection>){print $out $_;}; close($out); exit 0; } else { die "Error while forking: $@" unless defined $pid; } }
There may be a lot more to do to make this work with your real application, particularly if there is to be more than one connection at a time. In that case, the parent will need to listen on the socket and several pipes at once.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: multiple processes
by Mirage (Sexton) on Oct 25, 2001 at 14:09 UTC
    >It looks like your FIFO is only used for the child to
    >speak to the parent. Would a regular pipe serve better? It
    >would be faster.

    that is for testing purposes for now later i want it to be in both directions, however thanks for your help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://121383]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2022-12-02 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?