I set up a server with a ServerSocket, connect to it with a client machine. They\'re directly networked through a switch and the ping time is <1ms.
Now, I try to
Since I cannot yet comment on this site, I must write answer to @Erik here.
The problem is that DataOutputStream doesn't buffer. The whole Stream-thing in Java is based on decorators design pattern. So you could write
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
It will wrap the original stream in a BufferedOutputStream which is more efficient, which is then wrapped into a DataOutputStream which offers additional nice features like writeInt(), writeLong() and so on.