title: connection reset when trying to read inputStream
body: <p>I want to read a inputstream from a socket into a byteArray , but i get the follow error:</p>
  
  <pre><code>java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(Unknown Source)
  </code></pre>
  
  <p>I don't udnerstand why because i don 't close my socket until i finish to read the inputStream</p>
  
  <pre><code>try {
              in = connexion.getSocket().getInputStream();
              out = connexion.getSocket().getOutputStream();
  
              byte[] buffer= new byte[2048] ;          
              ByteArrayOutputStream baos= new ByteArrayOutputStream();
              int read = 0;
              while((read = in.read(buffer)) &gt; 0) // exception thrown here
              {
                  baos.write(buffer, 0, read);
              }
              reception = baos.toByteArray();
  
  
          } 
  
          catch (IOException e) {
              e.printStackTrace();
          }
          finally{
              try{
                  in.close();
                  out.close();
                  connexion.getSocket().close();
              }
              catch(IOException ioException){
                  ioException.printStackTrace();
              }
          }
  </code></pre>
  
  <p>Server side:</p>
  
  <pre><code> public static void main(String[] args) throws Exception {
          ServerSocket s = new ServerSocket(port,2);
          Socket soc ;
  
          while(true){
          soc = s.accept(); } }
  </code></pre>
  
  <p>Thank you very much</p>