I have a problem in my server/client TCP multiplayer game whenever I try to send too many messages in a short time (usually over 20 messages in the arc of 20 millis). After a while the messages start to arrive corrupted for some reason (like with integers in place of strings that usually get me a NumberFormatException).
I send informations as Strings using a DataOutputStream and read them with a Scanner.
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
in = new Scanner(inputStream);
out = new DataOutputStream (outputStream);
My questions are: should I use something different from the DataOutputStream/Scanner combination? Is there a faster combination? Should I turn the strings into bytes before sending them?
The strings I send are usually composed by both integers and strings, like "m 2 215 123" or "ep 2".