Bad value on output port 'tcp_inet'

Matthew Sackman <>
Mon Aug 14 17:45:54 CEST 2006


On Mon, Aug 14, 2006 at 09:49:55AM -0500, Logan, Martin wrote:
> You are using io:format to send the atom 'ok' over the wire.  io:format
> writes to stdout.  The docs for gen_tcp:send/2 indicate that it accepts
> the following payload type Packet = [char()] | binary().  Atom is not
> among them.  Try just firing off a string and see if it fixes your
> problem.

The documentation is wrong though: gen_tcp:send/2 will actually accept
any arbitrary combination of lists, chars and binaries. Which leads me
on to ask (apologies for thread hijacking): when constructing binaries,
is a new binary actually created or is it just pointer manipulation. The
reason for asking is that this:

Binary1 = get_a_binary_somehow(...),
Binary2 = get_a_binary_somehow(...),
gen_tcp:send(Sock, <<Binary1/binary, Binary2/binary>>),

seems to be slower than this:

Binary1 = get_a_binary_somehow(...),
Binary2 = get_a_binary_somehow(...),
gen_tcp:send(Sock, [Binary1, Binary2]),

Is this likely? What actually happens in the binary construction?

Cheers,

Matthew
-- 
Matthew Sackman

BOFH excuse #400:
We are Microsoft.  What you are experiencing is not a problem; it is an
undocumented feature.



More information about the erlang-questions mailing list