← Questions
Reassemble a stream of TLV messages in C
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Messages arrive over a byte stream in type-length-value (TLV) form: a type, a length, then that many bytes of value. The stream is delivered in chunks of arbitrary size, so one message may be split across several chunks and one chunk may hold several messages.
In C, write a reassembler that is fed chunks as they arrive and hands out each complete message exactly once. Explain how you buffer partial messages, how you handle a length that is too large or a malformed header, and how you keep copies and allocations down.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
