Do you know where your variables are? | |
PerlMonks |
Re: Need Help with Sockets, Pleaseby ferrency (Deacon) |
on May 09, 2002 at 14:19 UTC ( [id://165380]=note: print w/replies, xml ) | Need Help?? |
The code you wrote looks to me like it'll work only as long as the connection created in your IO::Socket::INET command stays up.
If a network outage occurs, if the remote end closes the connection,
or if the person or script sending input to your script via STDIN closes the pipe,
then one of your while() loops will finish and the corresponding process will die. Also: as it is now, if your child dies (remote connection close) but your STDIN keeps coming, the parent process will live on indefinitely, but it won't work very well. You could try to wrap the entire thing in a while (1) loop, but that wouldn't fix the problem of one process living on once the other exits. One way to fix this is to make sure the parent process is the one which exits its loop most often, and then to have it kill off its child process after the loop exits, since it knows its child's pid. Without seeing what you're doing in the while loops it's hard to tell whether this is the best way to do what you want. Be aware that after you fork(), you can't share new variable values between the parent and child processes. Your idea to share data through files can work, but beware of deadlock. Alan
In Section
Seekers of Perl Wisdom
|
|