Sockets: BufferedOutputStream or just OutputStream?

前端 未结 1 1495
既然无缘
既然无缘 2020-12-17 19:39

In order to get the fastest transfer speeds over TCP in Java, which is better:

Option A:

InputStream in = socket.getInputStream();
OutputStream out =         


        
相关标签:
1条回答
  • 2020-12-17 20:25

    I don't know where you read all that nonsense but it is completely back to front. The more you write at a time to a TCP connection the better, and the more you read from it at a time ditto. I would always use a buffered stream, reader, or writer between the application and the socket streams. There are some cases like SSL where directly writing a byte at a time can cause a 40x data explosion.

    Is it a good idea to touch the TCP window size? For example by setting it to 64 KiB

    You can't 'touch the TCP window size'. You can increase its maximum value via the APIs you mention, and that is indeed a good idea.

    0 讨论(0)
提交回复
热议问题