Erlang Language iolists Get IO list size


Example

Data = ["Guten tag ",<<"Hello">>],
Len = iolist_size(Data),
[<<Len:32>> | Data].

The size of an iolist can be calculated using the iolist_size/1. This snippet calculates the size of a message and creates and appends it to the front as a four byte binary. This is a typical operation in messaging protocols.