<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Before the call to the setopt, add a call to socket:setopt(Socket, otp, debug, true).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
/BMK<br>
</div>
<div>
<div><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0);">
<br>
<hr tabindex="-1" style="display:inline-block; width:98%;">
<b>From:</b> erlang-questions on behalf of Mark Geib<br>
<b>Sent:</b> Thursday, January 28, 2021 6:24 PM<br>
<b>To:</b> Erlang Questions<br>
<b>Subject:</b> problem with new socket module setopt()
<div><br>
</div>
</div>
<div class="rps_8505">
<div class="" style="word-wrap:break-word; line-break:after-white-space">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.
<div class=""><br class="">
</div>
<div class=""><font class="" face="Andale Mono"><span class="" style="font-style:normal"> {ok, GroupAddr} = inet:getaddr(Group, inet),<br class="">
{ok, SourceAddr} = inet:getaddr(Source, inet),<br class="">
{ok, IfAddr} = inet:getaddr(Interface, inet),<br class="">
IpMreqSource = #{multiaddr => GroupAddr,<br class="">
interface => IfAddr,<br class="">
sourceaddr => SourceAddr},<br class="">
<br class="">
{ok, Socket} = socket:open(inet, dgram, udp),<br class="">
{ok, Port} = socket:bind(Socket, #{family => inet, port => Port, addr => GroupAddr}),<br class="">
ok = socket:setopt(Socket, ip, add_source_membership, IpMreqSource),</span></font><br class="">
</div>
<div class=""><font class="" face="Andale Mono"><span class="" style="font-style:normal"><br class="">
</span></font></div>
<div class=""><span class="" style="font-style:normal"><font class="" face="Avenir-Book">I am using Erlang R23, latest release on debian-9 host.</font></span></div>
<div class=""><span class="" style="font-style:normal"><font class="" face="Avenir-Book">Any suggestions would be appreciated greatly.</font></span></div>
<div class=""><span class="" style="font-style:normal"><font class="" face="Avenir-Book"><br class="">
</font></span></div>
<div class=""><span class="" style="font-style:normal"><font class="" face="Avenir-Book">Mark.</font></span></div>
</div>
</div>
</div>
</body>
</html>