title: Unable to read data from InputStream
body: <p>I'm trying to learn java socket programming, but I have a trouble with the read function of InputStream.
  At first, I created a socket to connect to the server. After the connection is established, the server then send back the message that "the connection is established" and the read function is work fine. Then I tried to send byte message to the server, but I can't read the data from the InputStream because my program is stuck at "in.read(buf)" line. Could anyone point me out how can I solve this issue.</p>
  
  <pre><code>Socket client = new Socket("xxx.xxx.xxx.xxx", 45000);
      InputStream in = client.getInputStream();
      OutputStream out = client.getOutputStream();
      for (int i = 0; i &lt; 5; i++) {
          byte[] buf = new byte[1024];
          int data_size = in.read(buf);
          String msg = "";
          for (int j = 0; j &lt; data_size; j++) {
              msg += String.valueOf((char) buf[i]);
          }
          System.out.println(msg);
          out.write(65);
          out.flush();
      }
  </code></pre>