<div dir="ltr">I think in practice, given what Paul mentioned, it can't really be explicitly known or queried. Perhaps a simple handshake between the client and server could be done which tries to establish a practical msg size?</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 27, 2016 at 10:43 AM, Paul Peregud <span dir="ltr"><<a href="mailto:paulperegud@gmail.com" target="_blank">paulperegud@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This boils down to UDP being datagram protocol. It can't fragment<br>
packets by design, since it does not assume that it is operating on<br>
stream of data. Also, every packet is treated as something that can be<br>
dropped.<br>
<br>
So it may get dropped by anyone: network router, network adapter,<br>
kernel, or BEAM. On both sending and receiving side. As for reasons<br>
for dropping - packet is too big to fit into single ethernet frame,<br>
buffer (of any device or program) being full, connection being<br>
congested. In general UDP user needs to take care of all those things<br>
by himself.<br>
<br>
On bright side - UDP is cheaper and is better in some circumstances<br>
than TCP. I'm not aware though of any libraries that simplify UDP -<br>
but I'm not an expert at all.<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Jan 27, 2016 at 4:27 PM, Joe Armstrong <<a href="mailto:erlang@gmail.com">erlang@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I have a simple UDP client/server<br>
><br>
> The server is on a fixed port 4567 - I open it like this<br>
><br>
> {ok, Socket} = gen_udp:open(4567, [binary]),<br>
><br>
> then wait for registrations<br>
> receive<br>
> {udp, Socket, _Ip, _Port, <<"register">>) -><br>
><br>
><br>
> Clients do this:<br>
><br>
> {ok, Socket} = gen_udp:open(0, [binary]),<br>
> gen_udp:send(Socket, "localhost", 44567, <<"register">>),<br>
> ...<br>
><br>
> I'm testing on "localhost"<br>
><br>
> After registration the processes send binaries to each other<br>
><br>
> This works fine for small binaries but gen_udp:send fails with<br>
> {error,emsgsize} for large binaries<br>
><br>
> So I have a few questions:<br>
><br>
> 1) Can I find out the max binary size that can be sent/received?<br>
> 2) Can I increase the max size?<br>
> 3) Is there a guaranteed minimum packet length that will not be fragemented?<br>
> 3) Can received packets be fragmented - TCP has a {packet,N}<br>
> option and some built-in defragmentation, what's the story for<br>
> UDP?<br>
><br>
> I think I know the answers to these but I'm not really sure - could somebody<br>
> who really knows enlighten me?<br>
><br>
> Thanks<br>
><br>
> /Joe<br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Best regards,<br>
Paul Peregud<br>
<a href="tel:%2B48602112091" value="+48602112091">+48602112091</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>