I have an issue with a script I want to create for a Raspberry Pi using Python.
To test the script I'm running Python 3.6 on a Windows 64 bit machine. I want to send "1" to my local address (192.168.1.101 / 127.0.0.1) on port 1235, using TCP.
When I use putty in RAW mode, i can send this data to my server and I get the right response instantly.
But when I try to do this using Python on Windows I get a steady 2 minute delay. I can also see the command is only received by the server 2 minute after I send it. And after those two minutes I get an instant reply.
The code:
import socket
message = '\x31'.encode()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.1.101', 1235))
s.send(message) ; print ("send ready") ; data = s.recv(80) ; s.close(); print ("received"), repr(data)
#forgive me the ; ... I'm on a command line for testing.
#response is:
1
send ready
#2 minute delay
("None, "b"140,1,1,test\\r\n'")
I have been trying things like SOCKET_DGRAM
, RAW TCP NO DELAY
, SO_SNDBUF
, etc., but I can't find where this is coming from.