[erlang-questions] Getting the whole message with unix sockets

zxq9@REDACTED zxq9@REDACTED
Sun Nov 11 23:21:36 CET 2018


On 2018年11月11日日曜日 20時57分39秒 JST Joe K wrote:
> Actually, the problem is not with message truncation -- gen_udp never receives the full message at all. I've tried the same janus command with netcat, and it does receive the full message, so my problem must be with gen_udp. Is there some option that I can use to make it receive beyond 1460 bytes or at least break the big messages into several, and not drop the overflow silently?

UDP messages longer than the receive buffer will be truncated.
You can set the receive buffer size with the option {recbuf, Integer}:

{ok, Sock} = gen_udp:open(0, [binary, {recbuf, 4000}, {ip, {local, <<"/home/vagrant/erl.sock">>}}]).

or 

ok = inet:setopts(Sock, [{recbuf, 4000}]).

You can check the size of the receive buffer with `inet:getopts(Sock, [recbuf])` to help diagnose your problem.

-Craig



More information about the erlang-questions mailing list