My python program is talking to a device that will delay the conversation by an entire second each time it receives an ack to a push/ack. The conversation is hundreds if not thousands of messages long, so naturally I would like a way around this.
Is there a way to open a connection to my device, keep it open with the intention to send to it but don't ack messages I am receiving back with socket.recv()?
import socket
s = socket.socket()
s.bind(('', xxxxx))
s.connect(('x.x.x.x', xxxxx))
while True:
try:
msg = input()
if 'exit' in msg:
data = b'I am done now, bye'
s.send(data)
data = s.recv(2048)
print('recieved final message: ' + str(data))
break
msg = msg.encode()
s.send(msg)
print('sent message: ' + str(msg))
data = s.recv(2048)
print('received message: ' + str(data))
print()
data = ''
except Exception as e:
print(e)
s.close()
ACKs are essential to send when data are received. Otherwise the sender will simply assume that the data were not received and will try to resent the data. This will essentially stall the communication since only a (initially small) window of non-acked data is acceptable. Therefore it makes no sense to create such a connection and that's why there is no way to do it.