jtx has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use IO::Socket; # Make our connections my $ns1 = new IO::Socket::INET (PeerAddr => shell, PeerPort => 1200, Proto => 'tcp' ) or die "Couldn't create socket: $!\n" +; # Now let's fork the client so we can read and write my $pid = fork(); $fork_errlvl = 1 unless defined $pid; # If we weren't able to fork... die "Error forking client: Reason: $!\n" if $fork_errlvl != 0; if ($pid) { write_sock(); waitpid($pid, 0); } else { read_sock(); } sub write_sock { foreach my $key (@ARGV) { print $ns1 "$key\n"; sleep(1); } close($ns1); } sub read_sock { while (my $line = <$ns1>) { chomp($line); print "$line\n"; if ($line eq 'CAIO') { close($ns1); } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Activeperl 5.6 fork() doesn't friggin work
by tachyon (Chancellor) on Apr 18, 2002 at 00:45 UTC | |
Re: Activeperl 5.6 fork() doesn't friggin work
by premchai21 (Curate) on Apr 18, 2002 at 00:34 UTC | |
by Anonymous Monk on Apr 18, 2002 at 01:12 UTC | |
by premchai21 (Curate) on Apr 18, 2002 at 01:47 UTC | |
by jtx (Initiate) on Apr 18, 2002 at 18:20 UTC | |
by premchai21 (Curate) on Apr 19, 2002 at 01:57 UTC | |
Re: Activeperl 5.6 fork() doesn't friggin work
by Corion (Patriarch) on Apr 18, 2002 at 07:04 UTC |