[erlang-questions] Port Driver, outputv, binaries.

Matthew Sackman matthew@REDACTED
Thu Dec 10 12:20:07 CET 2009


Hi Tony,

Thank you very much for your email - that's very helpful.

I have one further question:

If I construct and send a binary with port_command, can I be guaranteed
that it'll not be split across two or more different binvs?

Eg

a) port_command(Port, [<<1,2,3>>]), or
b) port_command(Port, [<<"foo">>]), or
c) port_command(Port, [<<"foo",0>>]), or

c) is particularly important to me because I've noticed that if you send
a string down, it doesn't get null terminated, so sticking the extra 0
on the end is very important. It would be somewhat horrendous if that 0
could end up in a different binv entry from the "foo".

How about:

d) D = <<1>>, port_command(Port, [<<D/binary, 0, <<255>>/binary, <<"wibble">>/binary>>])

Is it safe to rely a binary being an atomic unit?

Matthew


More information about the erlang-questions mailing list