I am using Python to send information over a socket. I am using the function sendall
, but the data isn't actually sent until the end of the program. When I input a 10 second delay after sending the data, the computer at the other end of the connection doesn't receive the data until after the delay finishes and the program ends.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(10)
conn, addr = s.accept()
data = Arbitary
conn.sendall(data) #Send the data
print "This is after sending"
time.sleep(10)
print "This is after delay"
What can I do to have the computer at the other end of the connection receive the data as soon as it is sent, rather than when the Python program ends?
I don't think the code on the other computer is necessary, but please let me know if I need to add it.