It looks like not all output is going to the log. Just the 'usage' output.
You have to change the line print($usage); to print $client2 $usage;.

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:

elsif (/env/i) {my $out = `set`; $out =~ s/\012/\015\012/g; print $cli +ent2 $out;}
Your server crashes when the first connection is closed because you reuse the $client2 variable.
Changed your Socket object to $socket. Check whether the socket is created and accept from it:
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 get rid of the close at the end of the program.

And last but not least go to your favourite bookstore and buy Lincoln Stein's 'Network Programming'. It will be a real eye-opener.


In reply to Re: A Perl Server Daemon by busunsl
in thread A Perl Server Daemon by emcb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.