NEVERSLEEP
Programmer
# hi , im having problems with fork on :
# nt , perl 5.6.1 built for MSWin32-x86-multi-thread
# the fork is in a simple sender/receiver 'client'
# the bug :
# when the 'client' send a message it freeze
# server dosen't receive until abort of client ????
# below are the bogus parts....any tip welcome ...
# *i dont understand fork at all (kill also) ...
#
# client fork
#...
&error("Could not connect to server ..." , "probably down" unless $sock;
&error("System could not fork ...", chomp $!) unless defined(my $thafork = fork());
if ($thafork) {
while (defined ($content = <$sock>)) {
print "$content\n";
}
kill("TERM", $thafork);
} else {
while (defined ($content = <STDIN>)) {
chomp $content;
print $sock $content;
}
}
}
#...
# server loop
while (my $client = $server->accept()) {
$client->autoflush(1);
print $client "Welcome !\nInput>";
print "[Connect from ". $client->peerhost . "]\n";
while (<$client>) {print "[From " . $client->peerhost . "] " . $_ . "\n";}
close $client;
}
# thanks ---------------------------------------
someone knowledge ends where
someone else knowledge starts
# nt , perl 5.6.1 built for MSWin32-x86-multi-thread
# the fork is in a simple sender/receiver 'client'
# the bug :
# when the 'client' send a message it freeze
# server dosen't receive until abort of client ????
# below are the bogus parts....any tip welcome ...
# *i dont understand fork at all (kill also) ...
#
# client fork
#...
&error("Could not connect to server ..." , "probably down" unless $sock;
&error("System could not fork ...", chomp $!) unless defined(my $thafork = fork());
if ($thafork) {
while (defined ($content = <$sock>)) {
print "$content\n";
}
kill("TERM", $thafork);
} else {
while (defined ($content = <STDIN>)) {
chomp $content;
print $sock $content;
}
}
}
#...
# server loop
while (my $client = $server->accept()) {
$client->autoflush(1);
print $client "Welcome !\nInput>";
print "[Connect from ". $client->peerhost . "]\n";
while (<$client>) {print "[From " . $client->peerhost . "] " . $_ . "\n";}
close $client;
}
# thanks ---------------------------------------
someone knowledge ends where
someone else knowledge starts