Beginner Ping program

petercable at gmail.com petercable at gmail.com
Sat Apr 28 13:54:21 EDT 2007


On Apr 27, 10:54 pm, Linus Cohen <l... at fixedstars.com.au> wrote:
> Hi all,
> I'm a newbie to python and programming in general, so I wanted a
> simple project to start off. What I'm trying to do here is write a
> python command-line ping program, much like the Unix and Windows ping
> programs. I've got this much worked out already:
>
> class ping
>     def PING(IP, pings, size):

I agree with Marc here, probably no reason for a class here. As well,
if you are creating classes, generally class names should be
capitalized, methods should be lower case, i.e.

class Ping(object):
    def ping(self, ip, pings, size):
        ....

But, there really is no need for a class here, placeholder or
otherwise.

>
> and that's where I stop, because I realize I have no idea how to make
> python send ICMP request packets. My previous project(an email reader
> using poplib)used the stuff in section 18 of the modules
> index(internet protocols) but I can't seem to find an equivalent for
> ICMP packets. If anyone has help on this, I would really appreciate
> it.

There is no (that I am aware of) ICMP module in the standard library.
See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409689 for
an example of a Python implementation of ping.

>
> Cheers,
> Linus

HTH,

Pete




More information about the Python-list mailing list