Re: problem with new socket module setopt()

Mark Geib <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
Adding socket:setopt(Socket, otp, debug, true) did not seem to have any effect. I captured a snippet from the log below which may help.

2021-01-28T09:08:04.897919-08:00 [error] Supervisor: {local,ptc_6254_A_transport_sup}. Context: start_error. Reason: {badarg,[{prim_socket,nif_setopt,[#Ref<0.2135233317.2669019137.87142>,true,303,3002,#{interface => {172,24,4,30},multiaddr => {239,33,62,54},sourceaddr => {172,24,93,7}}],[]},{cse_socket,open_ssm_mc,
4,[{file,"/home/geib/git/cse.mpeg.invidi.pts_delta/apps/ipd/src/cse_socket.erl"},{line,87}]},{mpeg_ingest_rtp,init,1,[{file,"/home/geib/git/cse.mpeg.invidi.pts_delta/apps/ipd/src/mpeg_ingest_rtp.erl"},{line,49}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,417}]},{gen_server,init_it,6,[{file,"gen_server.er
l"},{line,385}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}. Offender: id=ptc_6254_A,pid=undefined.

Mark.


> On Jan 28, 2021, at 10:27 AM, Micael Karlberg <[email protected]> wrote:
> 
> 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.
signature.asc (application/pgp-signature, 528 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQEzBAEBCAAdFiEEYVHNuqOGsZElnxbO+5z0iCyWfG4FAmATHC8ACgkQ+5z0iCyW
fG7u2Af9Fa4fnJkVYra6TIN5rFnpv7Uj3j5E7H2CPxKmX5i+DDvMwAVvCJ0dyYVd
0MPwERbETPysfk4SnCjkoSieLm3Uku1rTqQb2tBda6dzP232tgPsTpseWEqUGWPj
X3yzdINdVeeJgYHoerz2XW2ctRd4eKzOyri0+BAMjQCZ2OckgLXmaKO+elzgb5fy
W19utn6t8Gv1jypT/0FxOI+/TG7IzOsmATceGZDcNjohKK1onKV/YPSz3wV67TZn
YEyx2/cFhC3D6dAB1DMqb5bNeRfYCeCLB0ZMFWyszraBJxij8Uwl9W6WnShPn6Pu
J9dUonbr5lxCjQyNxiOVi4+rlY7OGQ==
=lm6A
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.