title: inputStream data lost
body: <p>I am doing simple client-server in Java. This is my client code. </p>
  
  <pre><code> try {
          socket = new Socket(serverIP, serverport);
          dataStream = new DataOutputStream(new BufferedOutputStream(
                  socket.getOutputStream()));
          long[] data = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
          for (int i = 0; i &lt; data.length; i++) {
              dataStream.writeLong(data[i]);
              System.out.println("So far" + dataStream.size());
          }
       }
    } catch (IOException e) {
          e.printStackTrace();
      } finally {
          if (socket != null)
              try {
                  dataStream.flush();
                  socket.close();
                  dataStream.close();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
      }
  </code></pre>
  
  <p>This works fine because I can see that a mount of bytes have been written to the server. Here goes the server code.</p>
  
  <pre><code> try {
              ServerSocket newSocket = new ServerSocket(2503);
              while (true) {
                  connectionSocket = newSocket.accept();
                  input = new DataInputStream(new BufferedInputStream(connectionSocket.getInputStream()));                
                  System.out.println(input.readLong());
              }
  </code></pre>
  
  <p>However, none of data is successfully read from the server socket, the <strong>connectionSocket.getInputStream.available()</strong> returns 0 bytes. let's assume every variables were declared properly. Any idea why? Appreciate the help.</p>