[erlang-questions] Struggling with multicast udp send

Jarrod Roberson jarrod@REDACTED
Mon Nov 16 07:26:12 CET 2009


On Mon, Nov 16, 2009 at 12:41 AM, Rapsey <rapsey@REDACTED> wrote:

> This is copy paste from my server:
> Dest and Source are IP addresses (Source is IP of local computer, can be
> {0,0,0,0})
>
> {ok, Sock} = gen_udp:open(0, [{reuseaddr,true}, {ip, Source},
> {multicast_ttl, P#tspar.ttl},
>                                                 {multicast_loop, false},
> binary]),
> inet:setopts(Sock, [{add_membership, {Dest, Source}}]);
>

Thanks, but that works great for listen, but I can't get it to work for
sending.
Also I don't want to pass in 0 for the port, that gives me a random port, I
want to use port 5353.
All the other programs can send on that port, why can't erlang?
here is the output I get from iChat starting up.

From: {192,168,0,105}
Port: 5353
Data:
{ok,{dns_rec,{dns_header,0,false,'query',false,false,false,false,false,
                               0},
                   [{dns_query,"_presence._tcp.local",ptr,in}],
                   [{dns_rr,"_presence._tcp.local",ptr,in,0,4500,
                            "jhr@REDACTED
_presence._tcp.local",undefined,
                            [],false}],
                   [],[]}}

I get similar results with the exact same port 5353 from SubEthaEdit and
iTunes.

here is what I get when I try and send the message.

From: {192,168,0,105}
Port: 57345
Data: {error,fmt}

that is with passing in ZERO for the port on the :open() call.

and here is what I get when I try and make it send on 5353 like the other
programs

44> l(zcquery).
{module,zcquery}
45> zcquery:send().
** exception error: no match of right hand side value {error,eaddrinuse}
     in function  zcquery:send/0
46>

anyone have any arcane knowledge of how to get this to behave correctly?


More information about the erlang-questions mailing list