title: Message is only read by client after server closes the connection end in java
body: <p>I have been trying to send ISO8583 messages created with the JPOS Library in Java.
  What I have done is written a simple code of socket connection for sending message.
  I'm able to send the message successfully but the problem is the server sends a response on time but the message is not read by my client socket.
  It only reads the data after I close the connection forcefully (disconnect the socket manually) at server.</p>
  
  <p>I need to send more than 100 messages over the same connection and receive responses for them. What can I do to make this work and let the client immediately read each message when the server sends it?</p>
  
  <p>Here is my sample code for sending:</p>
  
  <pre><code>logISOMsg(isoMsg);
  byte[]  send_PackedRequestData = isoMsg.pack();
  BufferedOutputStream outStream=null;
  BufferedReader receiveStream=null;
  
  Socket connection = new Socket("127.0.0.1", 5874);
  if (connection.isConnected()) {
  
      outStream = new BufferedOutputStream(connection.getOutputStream());
      outStream.write(send_PackedRequestData);
      outStream.flush();
  }
  </code></pre>
  
  <p>and for reading:</p>
  
  <pre><code>if (connection.isConnected()) {
      receiveStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
      String isoMessage = receiveStream.readLine();
  
      ISOMsg isoMsg1 = new ISOMsg(); 
      isoMsg1.setPackager(packager);   
  
      byte[] bIsoMessage = new byte[isoMessage.length()];   
      for (int i = 0; i &lt; bIsoMessage.length; i++) {
          bIsoMessage[i] = (byte) (int) isoMessage.charAt(i); 
      }                                
      isoMsg1.unpack(bIsoMessage); 
  
      System.out.println("MTI='"+isoMsg1.getMTI()+"'");     
      for (int i=1; i&lt;=isoMsg1.getMaxField(); i++) {
          if (isoMsg1.hasField(i))
              System.out.println("DE : "+ i + " =  " + isoMsg1.getString(i) + "");
      }
  }
  </code></pre>