Works exactly like linux's ping command.
https://gist.github.com/shawwwn/91cc897 ... 34c38195fb
Example:
Code: Select all
>>> import uping
>>> uping.ping('google.com')
PING google.com (64.233.185.138): 64 data bytes
84 bytes from 64.233.185.138: icmp_seq=1, ttl=40, time=71.636004 ms
84 bytes from 64.233.185.138: icmp_seq=2, ttl=40, time=70.365000 ms
84 bytes from 64.233.185.138: icmp_seq=3, ttl=40, time=71.599998 ms
84 bytes from 64.233.185.138: icmp_seq=4, ttl=40, time=82.879000 ms
4 packets transmitted, 4 packets received
(4, 4)
>>>
Usage:
Code: Select all
uping.ping(host, count=4, timeout=5000, interval=10, quiet=False, size=64)
- @host: host's domain name or ip address to ping.
- @count: how many packets to send
- @timeout: stop if not receiving anything within a certain time period (milliseconds)
- @interval: time between sending each packet
- @quiet: suppress print messages
- @size: ICMP packet size (bytes), must > 16
- @return: tuple(number of packet transmitted, number of packets received)