I am trying to connect using TCP. In the client side I have the following code
import socket
BUFFER_SIZE = 1024
server_addres = ('172.16.1.52',3201)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(server_addres)
data = s.recv(BUFFER_SIZE)
s.close()
print "received data:", data
I run it using:
sudo python myProgram.py
This error appears
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 113] No route to host
However if i run:
sudo ping 172.16.1.52
The pings work properly. I need to run ping as sudo because running it without sudo gives ping: icmp open socket: Operation not permitted
It ended up being a routing policy of a radio interface. It didn't allow TCP packets. The rule was set by the IT deparment and could not be changed.
I reached this conclusion after sendind TCP packets to other hosts using another interface (ie my code worked)
I made sure there was a route. I manually set the routing table for the specific IP and made sure the input policy from the remote host was set to accept TCP packets.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.