Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting to socket fails after X bytes
    primarykey
    data
    text
    <p>I'm attempting to write song data to a socket however after approximately 66338 bytes the following exception is thrown:</p> <pre><code> E/ ( 1016): Connection reset by peer E/ ( 1016): java.net.SocketException: Connection reset by peer E/ ( 1016): at org.apache.harmony.luni.platform.OSNetworkSystem.writeSocketImpl(Native Method) E/ ( 1016): at org.apache.harmony.luni.platform.OSNetworkSystem.write(OSNetworkSystem.java:723) E/ ( 1016): at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:578) E/ ( 1016): at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59) E/ ( 1016): at com.myprogram.StreamProxy.processRequest(StreamProxy.java:307) E/ ( 1016): at com.myprogram.StreamProxy.run(StreamProxy.java:145) E/ ( 1016): at java.lang.Thread.run(Thread.java:1096) </code></pre> <p>This only happens with certain songs and if one song does it all of the songs in the entire album do the same thing. I'm wondering if it has something to do with the header information for the song?</p> <p>Any suggestions on how to debug or fix this would be greatly appreciated. Thanks.</p> <p>EDIT: Here's the code that is reading from an InputStream and writing back out to a socket. The code is pretty straight forward so I'm not really sure why it would be crashing unless the connection is being closed on the receiving end. (Note: this is only psuedocode, but gives the general idea)</p> <pre><code> InputStream data = realResponse.getEntity().getContent(); Socket socket = new ServerSocket(port, 0, InetAddress.getByAddress(new byte[] {127,0,0,1})); socket.setSoTimeout(5000); port = socket.getLocalPort(); Socket client = socket.accept(); ...some code... byte[] buff = new byte[1024 * 50]; while (isRunning &amp;&amp; (readBytes = data.read(buff, 0, buff.length)) != -1) { client.getOutputStream().write(buff, 0, readBytes); } </code></pre> <p>Also, could this have anything to do with the socket buffer filling up? Especially since it seems to crash at 64k every time.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload