You have no else block on the if (sysread($ircsock, $ircdata, 512)) { block, so you don't handle the case where the server closes the connection at all, which results in exactly the loop you're seeing.

As to why the server would close the socket when one of your clients disconnects, that may be because of the way the client is disconnecting. Most IRC clients will send a QUIT command to the server when they're about to disconnect, and I wouldn't be surprised if this causes the server to actively close the connection.

Since you don't do any special processing for the QUIT command, I suspect that as soon as one of your clients exits it will cause the server to close the connection to your "proxy". A possible workaround would be to intercept all QUIT commands and just ignore them.

On an unrelated note, I think your usage of sysread will get you into trouble. After each sysread you appear to expect that the result of a successful read will be a complete line. However there's nothing preventing sysread from returning half a line, or two lines at once.


In reply to Re^5: EOF being read from open socket? by Crackers2
in thread EOF being read from open socket? by Elijah

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.