Reputation: 13923
Scenario: client connect to a server using TCP and then the server sends 3 messages.
The server successfully sends 3 messages to the client. Meanwhile, the client machine receives the messages but the client didn't read any of them using dataInputStream.read
/...
Then, while the client starts reading the first message he received, the server closes the connection or the connection is lost for any other reason.
My question - Does the client will be able to read the data he didn't yet read but is available to him? or all the remaining data in the socket is unavailable for the client anymore?
Upvotes: 0
Views: 131
Reputation: 310884
These are two different scenarios.
Then, while the client starts reading the first message he received, the server closes the connection
No data is lost. The client will read all the data that was sent and then receive an end of stream.
or the connection is lost for any other reason.
All pending data is discarded.
Upvotes: 2