title: Socket closing with error
body: <p>I'm writing a bunch of data to a socket, however, after what seems like around 64k is written the socket is closed with an error "Connection reset by peer".  I believe what is happening is that what is reading the socket (Android media player) is dying when trying to read more data than is available from the socket.  This is a song that is being streamed and when the id3 tag is fairly large, it fails.  However, when I remove the id3 information from the song, it works fine.</p>
  
  <p>Since I believe that the reading side is failing when there is not enough data, I am wondering if it is possible to write a bunch of data to the socket before calling socket.accept() to accept the connection to read it.  My thinking here is that when the media player connects to the socket that there will be enough data for it to read and therefore not crash.  So can you call the write() before accept()?</p>
  
  <p>Here's some psudocode of my current code:</p>
  
  <pre><code>    ServerSocket socket = new ServerSocket(port, 0, InetAddress.getByAddress(new byte[] {127,0,0,1}));
  
      socket.setSoTimeout(10000);
      port = socket.getLocalPort();
  
      Socket client = socket.accept();
  
      ...
  
      while (isRunning &amp;&amp; (readBytes = data.read(buff, 0, buff.length)) != -1) {
  
          client.getOutputStream().write(buff, 0, readBytes);           
  
      }
  </code></pre>