Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1306

Python • Re: Ping with python and socket library

$
0
0
Thank you all for the replies guys.
I tried what @bensimmo suggested which is to ping the pi itself with the code. Once again it fails.
I noticed something. I am currently using the Thonny python IDE. The code does not build successfully in the IDE. I get the following errors :
******Errors****
>>> %Run my-hello-wrld.py
Traceback (most recent call last):
File "/home/pi/Desktop/testfolder/my-hello-wrld.py", line 50, in <module>
main()
File "/home/pi/Desktop/testfolder/my-hello-wrld.py", line 41, in main
success = send_ping(dest_ip)
File "/home/pi/Desktop/testfolder/my-hello-wrld.py", line 7, in send_ping
icmp_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
File "/usr/lib/python3.9/socket.py", line 232, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted
******Errors end****


I assumed the code should work when I run the script directly in the terminal even thougth it does not build properly in the IDE. Could I be wrong in this assumption?
Thanks a lot guys

Statistics: Posted by lecher8 — Mon Jan 08, 2024 6:44 pm



Viewing all articles
Browse latest Browse all 1306

Trending Articles