December 15th, 2013, 10:20 AM
Socket on Python
I'm new to this forum and to python. I started to learn python because I want to create automated scripts to control a remote device via TCP\IP.
I've already created a simple server\client code and tested it with remote computers.
Next step is to connect to a remote device using the following code (it works if I connect to a server created by me):
print ('INFO: Creating Socket')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip_addr = "10.20.11.5"
port_addr = 5000
print ('INFO: Connecting to server')
sta = time.clock()
# Listen for welcome
data = s.recv(4096).decode()
It returns a Time Out error:
INFO: Creating Socket
INFO: Connecting to server
Traceback (most recent call last):
File "C:\Python33\1\Client.py", line 25, in <module>
socket.timeout: timed out
Is there someone here who developed similar code comment on what might be wrong with my approach?
Thanks for looking!
December 15th, 2013, 02:39 PM
First thing to check is if the device is really listening on that IP address on port 5000. Can you try connecting with something like telnet and see if it responds?
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
December 15th, 2013, 02:41 PM
it does respond to connection to it at the same port and IP by a console application provided with it.