Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Rest" binary from binary_to_term

I want to use tcp to catch BERT-encoded messages, and I'm confused a little. binary_to_term(X) decodes only first term, without giving me back the rest of binary, nor saying how much did it use. Encode back with term_to_binary(X) to see it's size is not an option, because BERT-encoding methods differs(for example, it encodes all ints as long ints).

So, how do I decode the messages? The only valid option is passing the binary size too?

like image 519
desudesudesu Avatar asked Jun 05 '26 01:06

desudesudesu


1 Answers

Send size of the encoded term before the term itself. You can even use {packet, 2} option to read packets like this.

like image 198
Dmitry Belyaev Avatar answered Jun 07 '26 23:06

Dmitry Belyaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!