[erlang-questions] line_delimiter option in gen_tcp

Peter Devoy peter.devoy@REDACTED
Sat Oct 19 15:00:48 CEST 2019


Hi list

Figured it out.  For completeness and reference, my mistakes were two-fold:

1) Setting options on Listen socket instead of Accept socket.
2) Did not pattern match for "ok" on inet:setopts/2 so didn't realise
typing was
strict:
inet:setopts(AcceptSocket, [{line_delimiter, [0]}]).  %fails
inet:setopts(AcceptSocket, [{line_delimiter, "\0"}]). %fails

Eventually I got it to work with char notation but not before this mistake:
inet:setopts(AcceptSocket, [{line_delimiter, $0}]).   %ascii numeral 0
(fails)
inet:setopts(AcceptSocket, [{line_delimiter, $\0}]).  %ascii NUL (works!)

Final proof:
https://gist.github.com/PeteDevoy/30476594a1488c78106af1efe7de44bd

Thanks again


Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20191019/318c90f5/attachment.htm>


More information about the erlang-questions mailing list