I want to make Socket communication using bin_prot in OCaml. However, I can't find any detailed explanation or example to do that. I made Socket communication in the other way before, so I know the flow of it.
Do you have good explanations or examples to make Socket communication using bin_prot in OCaml?
Making socket communication using bin_prot
283 views Asked by mmsss At
1
Well, bin_prot is just a serialization protocol, and doesn't depend on whatever you're using for a transport layer. Basically, to serialize a value to string, you can use
Binable.to_string
function (orBinable.to_bigstring
). It accepts a packed module. For example, to serialize a set of ints, do the following:where
mine_set
is the set of integers.If you have your arbitrary type, that implements bin_prot, then it will work the same. An example would be: