Python Forum
Test internet connection - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Test internet connection (/thread-458.html)

Pages: 1 2


RE: Test internet connection - wavic - Oct-13-2016

(Oct-13-2016, 02:54 PM)micseydel Wrote: I ping 8.8.8.8, since it's a DNS server and tends to be very reliable.

How do you ping with python? Scapy?


RE: Test internet connection - Skaperen - Oct-13-2016

(Oct-13-2016, 02:54 PM)micseydel Wrote: I ping 8.8.8.8, since it's a DNS server and tends to be very reliable.

2001:4860:4860::8888 is the same machine.

(Oct-13-2016, 03:10 PM)wavic Wrote:
(Oct-13-2016, 02:54 PM)micseydel Wrote: I ping 8.8.8.8, since it's a DNS server and tends to be very reliable.

How do you ping with python? Scapy?

another way is with subprocess.


RE: Test internet connection - wavic - Oct-14-2016

(Oct-13-2016, 11:40 PM)Skaperen Wrote:
(Oct-13-2016, 02:54 PM)micseydel Wrote: I ping 8.8.8.8, since it's a DNS server and tends to be very reliable.

2001:4860:4860::8888 is the same machine.

(Oct-13-2016, 03:10 PM)wavic Wrote:
(Oct-13-2016, 02:54 PM)micseydel Wrote: I ping 8.8.8.8, since it's a DNS server and tends to be very reliable.

How do you ping with python? Scapy?

another way is with subprocess.
I don't like to use subprocess.


RE: Test internet connection - Skaperen - Oct-14-2016

(Oct-14-2016, 02:18 AM)wavic Wrote: I don't like to use subprocess.
is there some knowledge base around this that i do not have?


RE: Test internet connection - snippsat - Oct-14-2016

(Oct-14-2016, 03:08 AM)Skaperen Wrote:
(Oct-14-2016, 02:18 AM)wavic Wrote: I don't like to use subprocess.
is there some knowledge base around this that i do not have?
Yes subprocess is top secret stuff :silenced: 
import subprocess

website = "google.com"
ping = subprocess.Popen(["ping", website], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, error = ping.communicate()
print(out.decode('utf-8'))
Output:
Pinging google.com [193.212.4.59] with 32 bytes of data: Reply from 193.212.4.59: bytes=32 time=14ms TTL=60 Reply from 193.212.4.59: bytes=32 time=13ms TTL=60 Reply from 193.212.4.59: bytes=32 time=12ms TTL=60 Reply from 193.212.4.59: bytes=32 time=11ms TTL=60 Ping statistics for 193.212.4.59:     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:     Minimum = 11ms, Maximum = 14ms, Average = 12ms