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
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 | |
by perlgsm (Initiate) on Nov 18, 2013 at 15:13 UTC |