Using socket module in production?

pablo platt pablo.platt@REDACTED
Fri Jun 12 15:29:41 CEST 2020


Hi Raimo,

I don't mind small changes in the API if changes will be indicated in the
release notes.
But I worry about other breaking changes or hidden bugs.
If anyone from the community is already using it in production it will be
reassuring.

Thank you.

On Fri, Jun 12, 2020 at 4:00 PM Raimo Niskanen <
raimo+erlang-questions@REDACTED> wrote:

> Hi Pablo!
>
> We will still make backwards incompatible changes.  But we do not know of
> any stability issues, and welcome all that stress test the code.
>
> So your code might stop working work in a future 23.X release.
>
> / Raimo
>
>
> On Fri, Jun 12, 2020 at 01:48:32PM +0300, pablo platt wrote:
> > Hi,
> >
> > Is it safe to use the NIF socket module for UDP in production in OTP 23?
> > It's working in my tests but I'm not sure if it's considered unstable or
> if
> > I'm missing configuration or error handling.
> >
> > This is how I'm using it:
> >
> > open() ->
> >   {ok, Socket} = socket:open(inet, dgram, udp),
> >   {ok, Port} = socket:bind(Socket, any),
> >   {Socket, Port}.
> >
> > active_once(Socket) ->
> >     case socket:recvfrom(Socket, 0, [], nowait) of
> >         {ok, {#{port := Port, addr := Addr}, Data}} ->
> >             {udp, Addr, Port, Data};
> >         {select, {select_info, _SelectTag, SelectRef}} ->
> >             SelectRef;
> >         {error, Reason} ->
> >             exit(Reason),
> >             error
> >     end.
> >
> > send(Socket, Addr, Port, Data) ->
> >     Dest = #{family => inet,
> >              port => Port,
> >              addr => Addr},
> >     case socket:sendto(Socket, Data, Dest, [], nowait) of
> >         ok -> ok;
> >         {select, {select_info, _SelectTag, _SelectRef}} ->
> >             % need to wait for {'$socket', Socket, select, SelectRef}
> and
> > resend Data?
> >             ok
> >     end.
> >
> > close(Socket) ->
> >     socket:close(Socket).
> >
> > % listen for select ref
> > handle_info({'$socket', Socket, select, SelectRef}, _State) ->
> >     case socket:recvfrom(Socket, 0, [], nowait) of
> >         {ok, {#{port := Port, addr := Addr}, Data}} ->
> >             % handle Data
> >             ok;
> >         {select, {select_info, _SelectTag, SelectRef}} ->
> >            SelectRef;
> >      {error, Reason} ->
> >          exit(Reason),
> >          error
> >     end,
> >     {noreply, State}.
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200612/4c6a8b92/attachment.htm>


More information about the erlang-questions mailing list