[erlang-questions] constructing binaries question
Thu Sep 14 22:12:58 CEST 2006
I think your solution will work for me. The final goal is to send the
query to a socket, so the structure doesn't matter for pattern
matching. However, I do have to send the query after it's constructed
to an intermediate gen_server, which then sends the query to a process
that owns the socket. I know that sending binary messages involves
less copying than sending other types of messages, so I'm tempted to
construct the queries as binaries before sending them anywhere.
What's the best approach in this scenario?
> It depends on what you want to do with it. Most of the io functions
> understands lists of binaries. That being the case I usually just
> build up a list of binaries and give it directly to the io function.
> If you are passing the binaries around in your function then a list of
> binaries may not be a good choice, because it makes pattern matching
> the binary much more difficult (you don't know where the boundaries of
> each piece are so you can't assume a contiguous binary for matching).
More information about the erlang-questions