I'm new to socket programming and currently trying to learn it using Python
Currently I'm confused over when a receiving application knows when the sending application finished sending data.
For example, in Python, reading from a TCP socket is done using
socket.recv(bufsize [, flags])
buffer = socket.recv(1024)
buffer will return an empty array only if the client closes the connection.
If the client sends nothing, since TCP call is blocking in your case, the program stays blocked forever on
recv until data arrives or connection is closed (in which case data arrives empty).
(It's the same thing when you read a file on disk: you read data until data returns empty string/byte array: then you know you reached the end of the file)