简单的ping实施 [英] Simple ping implementation

查看:94
本文介绍了简单的ping实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要简单的ping操作,如果目标不可达,它将返回一些浮点数或无.我正在使用Python 3和Windows,并且不想使用标准输入法,因为我必须从shell解码字节并解析结果.我对ICMP协议的实现一无所知,因此准备使用库是最好的选择.

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.

推荐答案

您可以使用如下所示的纯Python实现:

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非特权ICMP

更新

一个非常简单的示例,无需修补Py 3:

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

https://github.com/volftomas/pyicmp

这篇关于简单的ping实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆