in reply to A Perl Server Daemon
The output gets garbled if I run the telnet client on windows, but is correct if I run it on Unix.
This is due to the line ending. You can do something like:
Your server crashes when the first connection is closed because you reuse the $client2 variable.elsif (/env/i) {my $out = `set`; $out =~ s/\012/\015\012/g; print $cli +ent2 $out;}
And get rid of the close at the end of the program.my $socket = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $PORT, Listen => SOMAXCONN, Reuse => 1); # Cant Start Daemon die "can't setup server" unless $socket; # Daemon Up And Running print "[Server $0 accepting clients]\015\012"; while ($client2 = $socket->accept()) { . . .
And last but not least go to your favourite bookstore and buy Lincoln Stein's 'Network Programming'. It will be a real eye-opener.
|
|---|