Note that there are some explanatory texts on larger screens.

plurals
  1. POHow big can the sendbuffersize in java Socket class be set to?
    primarykey
    data
    text
    <p>I have an application using an FTP library to transfer files. Receiving files works good, and mostly sending files also. The problem occurs when I'm trying to send a large file (3 MB), in which the application hangs. No error message, no nothing. I have debugged and found out that it stops in the <code>socketWrite0()</code> method in <code>java.net.SocketOutputStream</code>. This method never returns, but just hangs/blocks. It is called from:<br><code> java.io.BufferedOutputStream write() which calls <br> java.io.BufferedOutputStream flushBuffer() which calls<br> java.net.SocketOutputStream write() which calls<br> java.net.SocketOutputStream socketWrite() which calls<br> java.net.SocketOutputStream socketWrite0()</code><br> The file starts getting transferred, but the second time <code>java.io.BufferedOutputStream flushBuffer()</code> is called the transfer thread stops and hangs when it gets to the socketWrite0() method. I have tried adjusting the buffer size in BufferedOutputStream by sending a parameter in it's constructor, and it seems like it does not matter what this size is, it always stops on the second flush.</p> <p>Then I tried to set the Socket setSendBufferSize to 3 000 000, and suddenly everything worked as it should, with the BufferedOutputStream size being default. As long as I set this buffer size to an amount larger than the file size the file is transferred and everything is good! If I set the buffer size to i.e. 400 000 the transfer stops after this amount has been transferred.</p> <p>I cannot increase the BufferedOutputStream buffer unlimited. If I set this too big, the same thing happens: the application hangs at socketWrite0().</p> <ol> <li>Can anyone explain why?</li> <li>How large can the Socket buffer size be? What is the limit?</li> <li>How are the BufferedOutputStream buffer and the Socket buffer related?</li> </ol> <p>Thank you very much!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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