Why is InputStream.read() blocking here?

后端 未结 1 1612
深忆病人
深忆病人 2021-01-26 01:19

I am supposed to develop a simple SFTP.
Things were going fine until my ByteArrayOutputStream (in this case, baos) was not writing all of the

1条回答
  •  离开以前
    2021-01-26 01:48

    Your do/while loop runs until end of stream but the peer is never closing the socket. The protocol seems to require keeping the socket open for further commands, so you will have to adjust this part of it to include a length-word prefix so you know how many bytes to copy.

    The question isn't about ByteArrayOutputStream not writing all your bytes, it is about blocking in is.read().

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