<div dir="ltr"><div>I have used the socket module for udp sockets in production. I had hundreds of sockets at the same time receiving 5K packets/second and sending 25K packets/second.<br></div><div>I didn't encounter errors and didn't get bug reports from users. Seems to be very stable.</div><div>But I also didn't see any performance improvement compared to gen_udp.</div><div><br></div><div>I'm using socket:recvfrom(Socket, 0, [], nowait) and socket:sendto(Socket, Data, Dest, [], nowait).</div><div>Shouldn't I gain some performance over gen_udp?<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 12, 2020 at 7:31 PM Vans S <<a href="mailto:vans_163@yahoo.com">vans_163@yahoo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:13px"><div></div>
<div dir="ltr">We notice often using gen_tcp with sockets backend we get this warning printed:<br><br><span>3:24:4.923 <0.1018.0> [module: :gen_tcp_socket, socket: {:"$socket", #Reference<0.504347063.3068526593.55942>}, unknown_event: {:info, {:"$socket", {:"$socket", #Reference<0.504347063.3068526593.55942>}, :select, #Reference<0.504347063.3083599875.167918>}}, state: :connected]<br></span><br>Ignore the log format this is our custom format.<br><br>Seems to be some kinda race condition in the implementation.</div><div><br></div>
</div><div id="gmail-m_-2582830286614827590yahoo_quoted_1991383206">
<div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">
<div>
On Friday, June 12, 2020, 09:30:07 a.m. EDT, pablo platt <<a href="mailto:pablo.platt@gmail.com" target="_blank">pablo.platt@gmail.com</a>> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="gmail-m_-2582830286614827590yiv8181940438"><div><div dir="ltr"><div>Hi Raimo,</div><div><br clear="none"></div><div>I don't mind small changes in the API if changes will be indicated in the release notes.</div><div>But I worry about other breaking changes or hidden bugs.</div><div>If anyone from the community is already using it in production it will be reassuring.</div><div><br clear="none"></div><div>Thank you.<br clear="none"></div></div><br clear="none"><div id="gmail-m_-2582830286614827590yiv8181940438yqt91641"><div><div dir="ltr">On Fri, Jun 12, 2020 at 4:00 PM Raimo Niskanen <<a rel="nofollow" shape="rect" href="mailto:raimo%2Berlang-questions@erlang.org" target="_blank">raimo+erlang-questions@erlang.org</a>> wrote:<br clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Pablo!<br clear="none">
<br clear="none">
We will still make backwards incompatible changes. But we do not know of<br clear="none">
any stability issues, and welcome all that stress test the code.<br clear="none">
<br clear="none">
So your code might stop working work in a future 23.X release.<br clear="none">
<br clear="none">
/ Raimo<br clear="none">
<br clear="none">
<br clear="none">
On Fri, Jun 12, 2020 at 01:48:32PM +0300, pablo platt wrote:<br clear="none">
> Hi,<br clear="none">
> <br clear="none">
> Is it safe to use the NIF socket module for UDP in production in OTP 23?<br clear="none">
> It's working in my tests but I'm not sure if it's considered unstable or if<br clear="none">
> I'm missing configuration or error handling.<br clear="none">
> <br clear="none">
> This is how I'm using it:<br clear="none">
> <br clear="none">
> open() -><br clear="none">
> {ok, Socket} = socket:open(inet, dgram, udp),<br clear="none">
> {ok, Port} = socket:bind(Socket, any),<br clear="none">
> {Socket, Port}.<br clear="none">
> <br clear="none">
> active_once(Socket) -><br clear="none">
> case socket:recvfrom(Socket, 0, [], nowait) of<br clear="none">
> {ok, {#{port := Port, addr := Addr}, Data}} -><br clear="none">
> {udp, Addr, Port, Data};<br clear="none">
> {select, {select_info, _SelectTag, SelectRef}} -><br clear="none">
> SelectRef;<br clear="none">
> {error, Reason} -><br clear="none">
> exit(Reason),<br clear="none">
> error<br clear="none">
> end.<br clear="none">
> <br clear="none">
> send(Socket, Addr, Port, Data) -><br clear="none">
> Dest = #{family => inet,<br clear="none">
> port => Port,<br clear="none">
> addr => Addr},<br clear="none">
> case socket:sendto(Socket, Data, Dest, [], nowait) of<br clear="none">
> ok -> ok;<br clear="none">
> {select, {select_info, _SelectTag, _SelectRef}} -><br clear="none">
> % need to wait for {'$socket', Socket, select, SelectRef} and<br clear="none">
> resend Data?<br clear="none">
> ok<br clear="none">
> end.<br clear="none">
> <br clear="none">
> close(Socket) -><br clear="none">
> socket:close(Socket).<br clear="none">
> <br clear="none">
> % listen for select ref<br clear="none">
> handle_info({'$socket', Socket, select, SelectRef}, _State) -><br clear="none">
> case socket:recvfrom(Socket, 0, [], nowait) of<br clear="none">
> {ok, {#{port := Port, addr := Addr}, Data}} -><br clear="none">
> % handle Data<br clear="none">
> ok;<br clear="none">
> {select, {select_info, _SelectTag, SelectRef}} -><br clear="none">
> SelectRef;<br clear="none">
> {error, Reason} -><br clear="none">
> exit(Reason),<br clear="none">
> error<br clear="none">
> end,<br clear="none">
> {noreply, State}.<br clear="none">
<br clear="none">
-- <br clear="none">
<br clear="none">
/ Raimo Niskanen, Erlang/OTP, Ericsson AB<br clear="none">
</blockquote></div></div></div></div></div>
</div>
</div></div></blockquote></div>