Just a few minor points to enhance your example:
  1. You should probably use IO::Select to show how simple multiplexing IO can be done, or at least use non-blocking sockets ($socket->blocking(0)). The next question people ask is often along these lines, so take the initiative.
  2. If you're using IO::Socket, you should say $socket->close() instead of close($socket). Use object methods wherever possible.
  3. Likewise, you could be using $socket->getline() instead of <$socket> to read a single line. If you're so embittered about using IO::Handle ("thousands of lines") then why not make more use of it?
  4. s/protocal/protocol/i
  5. I'm not sure why you've indented your entire program four spaces. It ruins registration and is causing massive linewrapping problems in the PM code display window
  6. Your program is "paranoid" in that you are checking for a condition which can never be true. According to your code, there is no way that $mode could ever be 1 or 2, and you are checking for a hypothetical third condition. The only way this is going to happen is if you have bad ram, aliens abduct your computer, or you're hacking around in the debugger.
  7. Read up on IPC pipe code, and then post your explanation too. No sense in answering questions with a question.

In reply to Re: Newbies TCP Networking by tadman
in thread Newbies TCP Networking by otijim

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.