One problem with your code is that you have a typo: Net::SMPP-new_receiver instead of Net::SMPP->new_receiver. You should always "use strict;" which will catch that error.

Not knowing the complete context for your problem, I think that you want something like this:

my $channel = $rec[$RXThreadNumber]; my $select = IO::Select->new($channel); my $timeout=30; while ($channel) { my @ready = $select->can_read($timeout); if (@ready) { # If you add more sockets to select object, # this code will need to change if($pdu = $channel->read_pdu()) { print("Fetching pdu\n"); processpdu($pdu, $RXThreadNumber); } else { # eof or error on socket # you can do something like this: $select->remove($channel); $channel->close(); # Now, do you want to try to reconnect? If so, something # like this: if ($channel = TryReconnect($RXThreadNumber)) { $select->add($channel); } } } else { # Time-out print("Enquiring link...\n"); if($rec[$RXThreadNumber]->enquire_link()) { print("Link is fine...\n"); } else { print("Link is DOWN! Bringing up again...\n"); $select->remove($channel); $channel->close(); if ($channel = TryReconnect($RXThreadNumber)) { $select->add($channel); } } } } # We exit loop if we are no longer connected sub TryReconnect { my ($threadnum) = @_; $rec[$threadnum] = Net::SMPP->new_receiver( $tshost, smpp_version => $smppVer, system_id => $tssysid, password => $tspassword, system_type => $tssystype, dest_addr_ton => 0x91, dest_addr_npi => 0x00, addr_ton => 0x91, addr_npi => 0x00, source_addr_ton => 0x91, source_addr_npi => 0x00, port => $tsport ) or warn("can't connect to smsc: $!\n"); }

In reply to Re: SELECT help... by Thelonius
in thread SELECT help... by scuzzy

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.