problem with new socket module setopt()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

problem with new socket module setopt()

Mark Geib-2
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.


signature.asc (540 bytes) Download Attachment