Is there an idiomatic way using ktor native socket...
# ktor
a
Is there an idiomatic way using ktor native sockets to send over/receive objects?
s
I’d recommend https://github.com/Kotlin/kotlinx.serialization, perhaps with protobuf support.
a
@Sam Garfinkel If I send two protobufs over TCP in quick succession, when I read the byte array what I get is the concatenation of both requests. Is there a way to avoid this? (I am flushing)… I am guessing adding a byte specifying the legnth before sending each byte array?
s
Yeah you’ll need to create a meta-message for serializing your stuff. Protobuf doesn’t handle message delimitation for you.
The easiest way is to prepend the length to each message.