Check network connection from an IP address with Python

Nethan picture Nethan · May 29, 2013 · Viewed 26.6k times · Source

How can I check if there is still connection from a specific ip address using python.

Answer

Netorica picture Netorica · May 29, 2013

ping the ip address

import os
#192.168.1.10 is the ip address
ret = os.system("ping -o -c 3 -W 3000 192.168.1.10")
if ret != 0:
    print "pc still alive"

well in any case you really want to check for availability of incoming connection on the PC you are trying to connect you need to make a program that will receive the connection which is already out of the question.