title: Java: Sockets - DataStream really slow
body: <p>I'm using just normal DataInputStream and DataOutputStream in threads for receive, send (with accept on server) to make a game, but it is really slow. >5 seconds lag.</p>
  
  <p>Here is how I made it (most of it looks like that):</p>
  
  <p>(dos is DataOutputStream)</p>
  
  <pre><code>dos = new DataOutputStream(socket.getOutputStream());
  dos.writeFloat(dp.x);
  dos = new DataOutputStream(socket.getOutputStream());
  dos.writeFloat(dp.y);
  dos = new DataOutputStream(socket.getOutputStream());
  dos.writeUTF(dp.username);
  </code></pre>
  
  <p>And for Input (this one is in server) I use:</p>
  
  <p>(dis is DataInputStream, it's in a for loop so i is for each player)</p>
  
  <pre><code>dis = new DataInputStream(list_sockets.get(i).getInputStream());
  x = dis.readFloat();
  dis = new DataInputStream(list_sockets.get(i).getInputStream());
  y = dis.readFloat();
  dis = new DataInputStream(list_sockets.get(i).getInputStream());
  username = dis.readUTF();
  </code></pre>
  
  <p>So it is really slow, but I don't know why :(
  Please help?</p>
  
  <p>EDIT: Every operation (send, accept, receive) has it's own daemon thread.</p>