|laziness, impatience, and hubris|
Flaky Server (IO::Socket and IO::Select Question)by ginseng (Pilgrim)
|on Jun 12, 2001 at 09:41 UTC||Need Help??|
ginseng has asked for the
wisdom of the Perl Monks concerning the following question:
I'm working with perl in an industrial environment, running a machine control interface on OpenBSD. The interface communicates with a piece of industrial control equipment, a motion controller, that has an ethernet port. Almost everything is fine and dandy.
However, the motion controller's interface flakes out every now and then, and the link hangs. In essence, I need to break down and rebuild the connection. I know how to do this, but what I don't know is how to tell when I need to do this.
I'm using IO::Socket::INET to set up the link, and IO::Select to find out who can_read(). I thought of using a timeout on the can_read(timeout) call but the STDIN (actually redirected through TCPSERVER from the operator interface device) will reset that value when it wants more action. I'm using the Timeout value on the INET call: my $mcserver = new IO::Socket::INET(PeerAddr => $mchost, PeerPort => $mcport, Timeout => 6);
but it seems to have little effect. Finally, I've got an 'if' statement on my sysread:
which doesn't seem to cut the mustard either. In fairness I should note that this entry does make it into the log, about 8 minutes after the link fails. (In testing, I'm yanking the ethernet cable.)
Obviously, there's something I'm missing, a lack of understanding. I'm hoping you can help.
Ready for enlightenment,