aellis has asked for the wisdom of the Perl Monks concerning the following question:

I am 'snooping' the ICMP packets received by my host running some code that succeeds on UNIX but doesn't work properly on windows. First I successfully call....
socket( ICMP, PF_INET, SOCK_RAW, $proto ) ||
                                  die "socket failed: $!";
Later, I use select to detect an incoming ICMP packet.
    vec( $rin, fileno( ICMP ), 1 ) = 1;
    $ein = $rin;

    for(;;) {
	logMsg( "Entering Select\n" ) if( $::verbose > 0 );
	# timeout 5 minutes so messages show up in log
        my($nfound, $timeleft) =
            select($rout=$rin,$wout=$win,$eout=$ein,60);
The select successfully returns on timeout, but never detects when there is an ICMP packet coming in? On Solaris, this works properly. Any ideas?

Replies are listed 'Best First'.
Re: SOCK_RAW ICMP on windows
by pg (Canon) on Oct 27, 2003 at 22:57 UTC

    Go CPAN, check out Net::Pcap, which is an interface to pcap c lib.