Simple ping implementation [closed]

2019-02-19 09:37发布

I need simple ping that will return some float number or None if destination unreachable. I am using Python 3 and windows and don't want to use standart ping, cause i have to decode bytes from shell and parse results. I know nothing about implementation of ICMP protocol so ready to use library is the best choice.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-02-19 10:05

Active State Recipes is always the first place when I want to find such tiny/common/useful code snippets.

Here's one:

icmplib (Python recipe)

It works in Python3,

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-19 10:12

You could use a pure Python implementation like the following:

https://pypi.python.org/pypi/ping

or if you prefer this one:

http://www.python.org/~jeremy/python.html

and also take a look here, because they are discussing about the subject and you may find it useful:

python non-privileged ICMP

UPDATE

Without the need of patching for Py 3, a very simple example:

https://github.com/volftomas/pyicmp

查看更多
登录 后发表回答