altavir
09/09/2019, 7:21 AMInputStreamAsInput
. Current implementation seems to be bugged:
1) if I work with dynamic stream like the one I get from socket, it won't work since if input is empty, the input terminates. The input could be empty now, but not empty in the next moment. As a result I can't reliably convert socket input into Input
2) It uses internal ByteArray
pool and external IOBuffer
pool, but sizes of those buffers are not synchronized. If someone would use non-default IOBuffer
, It will probably break things.e5l
09/09/2019, 7:22 AMaltavir
09/09/2019, 7:26 AMInput/Output
API internally in the framework and now trying to establish direct communication via sockets (I can use Ktor for that, but I do not want to bring the whole framework for that). For last two days I was struggling to understand why I lose last few bytes of the message and now I understand that stream to Input conversion is the culprit. Maybe there is a better way to do it (something with channels maybe?).
I am currently trying to change implementation of InputStreamAsInput so it would work properly. I will post solution if I find one.override fun fill(): IoBuffer? {
val packet = stream.readPacketAtMost(4096)
return pool.borrow().apply {
resetForWrite(4096)
writePacket(packet)
}
}
Though for some reason I randomly get 8-bytes buffers from borrow
how is it possible if the pool is for 4096 bytes buffers?