A socket connection is two unidirectional flows: one from client to server and one from server to client.
Each side can put data in one stream and read from the other.
Data placed in one stream is added to the end of existing data.
When data is read from one end of the stream, the oldest available data will be read (i.e. the stream is FIFO).
These statements should allow you to answer all your questions, but I will also make this explicit:
- The server will read only what the client wrote, and not what he wrote himself
- First, the server will read the old material, and then the new material
- The client does not have an immediate way to find out if the data was actually received by the other party if the server did not send anything in response. In some circumstances, he may know that the dispatch failed (for example, when there is a physical problem on the client side), but, as a rule, cannot rely on this notification.
source share