Hello,

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:

if ($handle == $mcserver) { if (sysread $handle, $result, 1024) { # ... deal with it ... } # if the program gets here, the controller went away. else { logger("Motion controller died unexpectedly."); $mcserver->shutdown("SHUT_RDWR"); $links->remove($mcserver); $mcserver = new IO::Socket::INET(PeerAddr => $mchost, PeerPort => +$mcport, Timeout => 6); $links->add($mcserver); }

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,
ginseng


In reply to Flaky Server (IO::Socket and IO::Select Question) by ginseng

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.