Open sshah254 opened 8 years ago
In pyping, the author has something like this (I'm sure you are aware of something like this):
try: # One could use UDP here, but it's obscure
if self.udp:
current_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.getprotobyname("icmp"))
else:
current_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp"))
except socket.error, (errno, msg):
if errno == 1:
# Operation not permitted - Add more information to traceback
etype, evalue, etb = sys.exc_info()
evalue = etype(
"%s - Note that ICMP messages can only be send from processes running as root." % evalue
)
raise etype, evalue, etb
raise # raise the original error
Sandip
Sandip, I assume you mean your laptop is WiFi connected and you are testing a remote host on the WiFi network. In this case, aborting with "No route to host" is likely the best reaction for ping.py. If we are waiting for a remote host to come up or go down and we loose our ability to recognize if that host is up or down, I think most people will want to know right away (so they aren't tricked into waiting for the host forever when the problem is with the laptop).
Also, I don't know if adding the UDP option is that useful.
Hi Duane,
Thanks for the response.
I am connected via wifi to a router to which the host is connected via cable - a simple setup.
When I lose connection to this wifi, the laptop automatically switches to a different wifi. There is no route from this wifi to the host, and hence the error.
When the original wifi comes back on, I want the program to continue (rather than restart it). While it is not able to reach the host, just keep on printing the error (and not go down).
Is this possible?
Sandip
Hi,
Thanks for creating this tool.
If I lose my wifi connection, then I get this error (I am pinging 10.10.1.119:
Exception in thread 10.10.1.119: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "ping.py", line 58, in run self._function(self._args) File "ping.py", line 223, in _ping self.sock.send(self._icmp_create(pdata)) error: [Errno 65] No route to host
Let me know if you can fix the issue, or how I can fix it. A try / catch block might help there.
On lines 298, 311, and 313 you are using str as a variable which is a reserved word in Python (I switched it to str1, maybe you can do something similar).
For my own purposes, I changed line 298 to:
...
since I want to know the exact time at which something goes down.
Thanks,
Sandip