Re: Question for multicast




In article news:D867E404-66E3-4B04-8119-C1E2D1BE0849@xxxxxxxxxxxxx,
June wrote:
Hi

I am implementing multicast on Windows server 2003. I found I cannot
bind to a specific multicast address when created a socket. Code as
follows:

[...]
sa.sin_addr.s_addr=INADDR_ANY; //If I set it to multicast address, it
will return
//error 10049 when
calling bind(..)

if (bind(sock, (LPSOCKADDR) &sa, sizeof(sa))==SOCKET_ERROR)
return 0;


bind(...) sets the *source* address not the destination address. Just don't call bind at all.

//next call setsockoption to join the group so the host can send and
receive from the group.

(If you only want to /send/ multicast there's no need to set any socket option (do a join etc)).


So it looks like I have to assign INADDR_ANY to the address when
allocate and bind the UDP socket for multicasting. I can assign the
socket with a specific multicast address. Is it right? If yes,
what if I need listen to more than one multicast group? Seems I
cannot create another socket with INADDR_ANY again since the address
is already binded to an existing socket. Does it means we need listen
to same socket for all multicast group?

As above, doing bind(...) is not what you want. To listen to multiple multcast addresses just do multiple mulicast "joins".
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.

.



Relevant Pages

  • Re: Too much multicasting in Linux
    ... that didn't join the multicast address where the data is being sent. ... if I have a socket that joins the SAME ... multicast group but is tied to a different interface it will not receive ... > Only on the receiving side you must join a multicast group ...
    (comp.os.linux.networking)
  • Re: socket question: how to use sendto and recvfrom based on the same multicast address
    ... Why don't you just use the same socket for both send and receive? ... multicast address and receive other data from others on the samd ... closesocket; ... if (setsockopt (sockrcv, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Question for multicast
    ... I am implementing multicast on Windows server 2003. ... bind to a specific multicast address when created a socket. ...
    (microsoft.public.win32.programmer.networks)
  • AF_IPN: Inter Process Networking, try these...
    ... If you suspect we would be better using IP multicast, ... Exercise #1. ... I Create a IPN socket, with protocol IPN_VDESWITCH and all the VM can ... or a binary stream. ...
    (Linux-Kernel)
  • Re: Question for multicast
    ... I am implementing multicast on Windows server 2003. ... bind to a specific multicast address when created a socket. ...
    (microsoft.public.win32.programmer.networks)