<@U4CP1J0QP> I was looking at this issue <https://...
# ktor
e
@e5l I was looking at this issue https://github.com/ktorio/ktor/issues/654 More or less I'm having the same problem. In an old implementation of the TCP protocol I'm re-implementing they were using Java's
Socket.getInputStream().available()
to know the available bytes in the read buffer. That buffer is 65k bytes, which more or less means I need a couple of iterations to read the entire server response. I know it's a weird way to implement a protocol, but I can't do anything about it now. With Ktor I find myself reading 4k bytes at a time (
availableForRead
), which slows it down quite a bit, also because the buffer doesn't seem to be immediately refilled. Is there a way I can use an arbitrary size for that buffer? I'm not sure your answer there applies here.
I think I can workaround this by changing how I read data from the server. I've seen
ByteReadChannel
has a
readUTF8Line
method. Which is mostly what I'd need. However my protocol doesn't operate using UTF-8, but using charsets like CP037 or CP1047. Could I implement my own
readLine
method - that doesn't decode the byte stream - using utilities that are already present?
e
Hey @Edoardo Luppi, thanks for the report. We're working on migrating to the new kotlinx-io library. After migration the issue should be fixed
e
No problem @e5l, I've built my own workaround for now and it works ok! I really like kotlinx-io stuff btw, hopefully it will include much more utilities going forward
My use case is a custom TCP protocol with multiplatform support
👍 1