Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Checking if a socket has some data to read

by 5mi11er (Deacon)
on Jun 14, 2013 at 16:16 UTC ( [id://1038990]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Checking if a socket has some data to read
in thread Checking if a socket has some data to read

Hmm, no, I think you're confusing can_read with the routine that actually does the reading, you're confusing a scalar variable with an array, and I can't tell if you've turned buffering off on the $lsn file handle, but I'm guessing not.

Your code:

$results = $sel->can_read(0);# or die "cant read"; #print Dumper @results; print "\n****Outside if****"; print "results== $results\n";

Ping code:

if ( $select -> can_read( 0 ) ) { my $remote = recv ( $pinger, $buff, SIZE, RCV_FLAGS ); if ( $debug ) { print "result from ", unpack("C*",$remote), ":", unpack ( "C*", $target_addr), "\n"; } # sometimes ICMP replies come from other devices, filter those out if ( $remote eq $target_addr ) { $received++; } }

So, you've, at best, got a boolean result from the can_read, but then you use that as if can_read returned an array of data from the wire, rather than use a recv() call to actually read the data properly.

I'm also betting that you're Suffering from Buffering, which means unless you've tested by sending tons of stuff, the buffer never filled up, and it *LOOKS* like you've not received anything.

-Scott

Replies are listed 'Best First'.
Re^4: Checking if a socket has some data to read
by perlgsm (Initiate) on Nov 08, 2013 at 09:18 UTC
    Thank you Scott and my apologies for the late reply. I will read this today or next week and try to implement your suggestions. You may be right I may be suffering from buffering. Receiving some data is the only piece not working in my script and stopping it from becoming, what I want. I will get back to you. Kind regards. Cheers!
    God bless world peace...
      Hi Scott, I don't think my script is suffering from buffering. I think some issue with the CPAN library. I used IPC and created a child process, but for some reason the parent's request (heartbeat) isn't sent to the server, I think the child's read request is blocking the call. Which as per CPAN-SMPP library is expected. While child gets different offset, surprisingly it is an issue sometimes, not always. I'm thinking of emailing the module developer. Thanks a bunch.
      God bless world peace...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1038990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-18 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found