Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: TCP/IP

by mikfire (Deacon)
on Apr 05, 2000 at 07:29 UTC ( [id://6925]=note: print w/replies, xml ) Need Help??


in reply to TCP/IP

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 )

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6925]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2024-03-28 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found