Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

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



  • 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 sharing their wisdom with the Monastery: (4)
As of 2024-04-19 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found