[erlang-questions] "Bad value on output port 'tcp_inet'" for null terminated messages

Jani Launonen launoja@REDACTED
Thu Sep 10 20:20:44 CEST 2009


> Hi,
> 
> ok = gen_tcp:send(Socket, "message text"),
> 
> seems to work (the receiving end is of course confused), but
> 
> ok = gen_tcp:send(Socket, "message text\0"),
> 
> gives
> 
> =ERROR REPORT==== 10-Sep-2009::20:21:21 ===
> Bad value on output port 'tcp_inet'
> 
> 
> How can I send the trailing 0-byte?

How about:
ok = gen_tcp:send(Socket, ["message text", 0]).

I haven't tested that this actually works (my erlang environment is missing after a update and with 2.5G data downloading one is taking quite lot of time) :)

But:
"An I/O list is a binary or a (possibly deep) list of binaries or integers in the range 0..255."
Says Erlang Reference Manual about Port BIFs.
 
> This is erl5.7.2 on XP.
> 
> 
> Thanks,
> -juhani

You're most welcomed,
Jani 

> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 
> 


More information about the erlang-questions mailing list