Creating binary from list variables?
Tue Dec 14 14:44:58 CET 2004
Hello, here is another newbie question. I have read chapter 6.16 of the
Reference Manual, but not succeded to solve this problem.
How do I create a binary, to send with gen_tcp:send, from variables of
different types and dynamic length, when I want the final binary to be of
fixed length? (As it usually is defined in socket interfaces)
I keep getting "badarg" when I try different approaches for lists:
AsciText = "Hello there!",
Number = 123,
Binary = <<AsciText:120, Number:32>>,
AsciText = "Hello Sam!",
AsciAsBinary = list_to_binary(AsciText),
Number = 1239,
Binary = <<AsciAsBinary:120, Number:32>>,
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
More information about the erlang-questions