problem with new socket module setopt()

Micael Karlberg micael.karlberg@REDACTED
Thu Jan 28 18:27:29 CET 2021


Before the call to the setopt, add a call to socket:setopt(Socket, otp, debug, true).

/BMK


________________________________
From: erlang-questions on behalf of Mark Geib
Sent: Thursday, January 28, 2021 6:24 PM
To: Erlang Questions
Subject: problem with new socket module setopt()

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/1b60a5c1/attachment.htm>


More information about the erlang-questions mailing list