in reply to
A proposal for improvements to Net::Ping
I might take issue with some of your proposals: (I've taken the liberty of numbering your points)
- Looks good. Makes sense.
- Hmm. I'm a little hazy on this one, but I'd say that calling ping in backticks would be a bad idea. 1) You don't know which binary will execute since you are not providing an absolute path. A config script would be needed to get this right. I find that too complicated for this nice all-Perl module. 2) ICMP echo was intended for privileged users. Don't try to circumvent this in this library. No other UNIX lib allows you access to ICMP. Only some tools are setuid(0). Abusing this in a lib is a bad idea. 3) The returned string from the backtick call will be very system dependent. It would have to be configured individually for every system and various versions of ping. If you don't have access to ICMP, then you don't. Forget it and try something else.
- Interesting, but sort of "beginner's"-level functionality. I guess it might work, but it might take a long time to confirm a computer's existence if each level has to fall back on the next. The newbie may become entirely discouraged after waiting for 15 seconds for ping results for the machine next to him. Instead, in the docs, explain that it may be beneficial to use `ping` instead of this module under certain circumstances.
- alarm would be poor programming style to begin with. This should immediately be replaced with a select or setsockopt with SO_RCVTIMEO or fiddle with IP_TTL (choose appropriately for each protocol).
- This is something I wouldn't like at all. Again, it may seem like "cool" functionality for the beginning user, but it is really misleading. It can too easily get out of control and wastes resources. Such things are best left to threads and threaded apps like sping which does exactly what you wish already. Imagine the user firing off 20 of these pings, all of which fork off a `ping`. That's 40 processes==bad news==looks like runaway process. Instead, humbly suggest the use of sping in your docs or make your function simply line them up for pinging. By the way, how would you be returning results? You would be waitpiding say for 20 processes which fire off `ping` to exit, all of which take .25 seconds to startup (theoretically speaking), then you have a maximum wait of 15 seconds even if you specified a timeout of 5 seconds- very confusing stuff here. If the user wants to waste his time doing that, then let him, but don't build this into a much used and abused library.
I'd be happy to try your new version on AtheOS, perhaps one of the most obscure yet user-friendly OSs in existence. Good luck!
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.