ok guys, I thought flushing the buffer would help, apparently not. I'm using select as a sort of timeout for data on an incomming socket. The scenario goes like this. I've got a socket waiting for data, if it's there enterpret it, if however, no data has been recieved within 30 seconds, check the status of the line with a pseudo ping to make sure the host on the other side is listening. Here's the problem, when the aplication starts, it never times out, ONLY when I press return on the kb does it start to time out. I'm thinking it's because for SOME reason, the socket wasn't updated and it's still waiting for data on it, wich wasn't the case.
my $selectFD; $selectFD = new IO::Select($rec[$RXThreadNumber], undef, undef, 1); $|++; # flush the buffer apparently... while(@bits = $selectFD->can_read) { select(undef, undef, undef, 0.1); foreach $fdThread (@bits) { if($fdThread == $rec[$RXThreadNumber]) { print("Fetching pdu\n"); # the following if is to make sure that the only time we try + fetch an sms # is when there is actual sms activity on the socket... and +nothing else... # this was causing problems before because a sock kill init +was creating# noise on the line and the aplication was trying to ent +erperet this as # a PDU... if($pdu = $rec[$RXThreadNumber]->read_pdu()) { print("CMD: $pdu->{cmd}\n"); print("STATUS: $pdu->{status}\n"); print("SERTYPE: $pdu->{service_type}\n"); print("SEQ: $pdu->{seq}\n"); print("SOURCE: $pdu->{source_addr}\n"); print("DESTINATION: $pdu->{destination_addr}\n"); #print("DATA: $pdu->{data}\n"); print("MESSAGE: $pdu->{short_message}\n"); $test = $rec[$RXThreadNumber]->deliver_sm_resp(seq=>$pd +u->{seq}, message_id=>''); my $nowRXTime = genTime(); my $queryRX = $tdbh->prepare("insert into MOHits values +(NULL, NULL, \"$pdu->{source_addr}\", \"$nowRXTime\", \"$pdu->{short_ +message}\", 0, \"$pdu->{destination_addr}\")"); $queryRX->execute; print("Fetched pdu\n"); } } if((time() - $startTime) > 5) { $startTime = time(); print("Enquiring link...\n"); if($rec[$RXThreadNumber]->enquire_link()) { print("Link is fine...\n"); } else { print("Link is DOWN! Bringing up again...\n"); $rec[$RXThreadNumber] = Net::SMPP-new_receiver( $tshost, smpp_version => $smppVer, system_id => $tssysid, password => $tspassword, system_type => $tssystype, dest_addr_ton => 0x91, # Type Of Number, +this means its "2783XXXXXXX" 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"); } } } }
The timeout ONLY fires when I press return on the kb once the aplication starts.... any idea's? Thanks Scuzz. (;

In reply to Re: Re: flushing sockets by scuzzy
in thread flushing sockets 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.