in reply to Why does Net::Ping behave this way?

The TCP and UDP pings require the echo service to be running. Most security concious folk will have this disabled by default (or probably blocked at a firewall) as it serves no real useful purpose (other than for people using Net::Ping :).

To answer the questions, in the first case the TCP connection probably hit a real machine with no TCP echo service running (which promptly returned something telling your TCP stack that a connection couldn't be made). Then it hit an address that was either firewalled or not there, so it didn't hang in as much as it was waiting for the connection to be established (most implementations will wait about 2 minutes before returning an error in this case).

In the second case, there probably was nothing running a UDP echo service so you saw no replies (or a firewall was dropping all UDP traffic).

As for the final case, the error message sums it up: you were trying to do something that requires root privledges on most real OSen. Sending ICMP traffic requires access to a raw network socket, which means you can pretty much send whatever packets you'd like (meaning you could inject spoofed traffic onto the network). J Random User isn't allowed to do this (which is a good thing). You'd need to run the program as root (or have it setuid to root; in which case you'd need to be aware of the security implications that brings :) in order for it to work. If you look at your system's ping utility you'll see that it's setuid to root.

Replies are listed 'Best First'.
Re: Re: Why does Net::Ping behave this way?
by rbc (Curate) on Apr 02, 2002 at 23:57 UTC
    Thanks for the info Fletch.
    I found this node, 24583, out there you might find it interesting
    too. As it seems to be a work around for icmp problem
    I was having without having to setuid.