Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-28 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found