Design idea for Ping Application
David M. Cooke
cookedm+news at physics.mcmaster.ca
Tue Aug 19 17:58:24 EDT 2003
At some point, "Mike C. Fletcher" <mcfletch at rogers.com> wrote:
> Jeremy Hylton wrote:
> ...
>
>>Years ago I wrote ping in Python. I don't have the code anymore, but
>>there's not too much too it. One of the Stevens books has C source for
>>a simple ping, and it's not much work to adapt the basic design to
>>Python. It's far simpler than the C code.
>>
>>If you had a simple ping library in Python, it would be easy to run
>>several Ping instances in a single select loop. Then you don't need to
>>bother with threads and pipes and shells.
>>
> As pointed out by a previous poster, it's available from Python.org.
> We've got a version which fixes a few (trivial) bugs (use of 'h'
> instead of 'H' in struct formats mostly, to indicate unsigned rather
> than signed ints). Works nicely on Win32, however, I've not yet been
> able to get the code to run under Unix (where creating raw sockets is
> a no-no).
Only root can create raw sockets. You'll notice the system ping
command is setuid root so that ordinary users can use it. Running this
code as root works.
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
More information about the Python-list
mailing list