problem with new socket module setopt()

Mark Geib mark.geib.44@REDACTED
Thu Jan 28 18:24:22 CET 2021


I am using the new socket module in order to join a source-specific multicast and receive datagrams. The following code fails with a “badarg” error on the socket:setopt() call. I have carefully checked the docs for R23, but can not find the problem.

    {ok, GroupAddr} = inet:getaddr(Group, inet),
    {ok, SourceAddr} = inet:getaddr(Source, inet),
    {ok, IfAddr} = inet:getaddr(Interface, inet),
    IpMreqSource = #{multiaddr => GroupAddr,
                     interface => IfAddr,
                     sourceaddr => SourceAddr},

    {ok, Socket} = socket:open(inet, dgram, udp),
    {ok, Port} = socket:bind(Socket, #{family => inet, port => Port, addr => GroupAddr}),
    ok = socket:setopt(Socket, ip, add_source_membership,  IpMreqSource),

I am using Erlang R23, latest release on debian-9 host.
Any suggestions would be appreciated greatly.

Mark.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210128/ac5599d1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 528 bytes
Desc: Message signed with OpenPGP
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210128/ac5599d1/attachment.bin>


More information about the erlang-questions mailing list