I have a server application and a client applet and I want to know what the best way to communicate between them is. I have thought of two possibilities.
The first one is a text-based protocol where messages are sent by using DataOutputStream.writeUTF(String str).
In the other a code (byte) describing the message is sent first, and then data in various formats (byte, long, String). Less data (in bytes) would be needed to sent but the problem is that if the receiver didn't read the right number of bytes, the next messages would be screwed up.
Which method would you recommend or is there an article I should read?
Edit: It is a multiplayer game. If a player's status changes (which happens often), the new status needs to be sent to other players.
[ March 28, 2006: Message edited by: Matti Poro ]