If I have analyzed this correctly - and it took some time to figure that out - your problem is in the block
while($nodie) { while(<LOGREQ>) { if(! print $_,"\r") { confess "can't print to socket: $!"; $nodie = 0; last; } } }
Instead of the last, you need to exit. The example you reference is, according to my Camel, using an exec() which performs much magic ( which I can explain offline if you wish ). The end result, though, is that the spawned child exits when the command ( fortune ) finishes.

If I have figured this out correctly, your last only drops you out of the innermost loop - the while(<LOGREQ>) loop. Perl transfers control to the next outermost block - which is the while ($nodie) in this case. $nodie as always 1.

So your code is constantly trying to write to a closed socket, failing, it executes the last and then this loop all over again.

If you change the last to an exit, the forked process will die on error, not get its poor little head caught in an infinite loop.

Of course, I could be wrong. I am still not certain on a few aspects of this code.

Mik
Mik Firestone ( perlus bigotus maximus )


In reply to Re: TCP/IP by mikfire
in thread TCP/IP by Jason0x21

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.