I'm currently working on a simple client/server file synchronization. For this, client and server follow a simple protocol which determines in which order messages are sent.
shortened protocol (Using Object/ByteArrayStreams):
Client loop:
Server loop:
Repeat.
The problem is the protocol gets out of order when an error occurs during transmission and I usually get StreamCorruptedExceptions, since at least one side is expecting something else.
Here is a sample situation of the problem: Server fails during file reception (3) for whatever reason. Now the server waits for a filename. Because of the error, the client arrives at part 3 sending the data. Then the the Exception is thrown since the server expects a message object and the client sends byte data.
What is the best way to solve this?
some thoughts
Other thougt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With