Re: Question for multicast
- From: "Alan J. McFarlane" <alanjmcf@xxxxxxxxxxxxxxxxx>
- Date: Sat, 18 Aug 2007 15:23:38 +0100
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(If you only want to /send/ multicast there's no need to set any socket option (do a join etc)).
receive from the group.
So it looks like I have to assign INADDR_ANY to the address whenAs above, doing bind(...) is not what you want. To listen to multiple multcast addresses just do multiple mulicast "joins".
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?
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.
.
- Follow-Ups:
- Re: Question for multicast
- From: June
- Re: Question for multicast
- Prev by Date: Re: Question for multicast
- Next by Date: Re: Multi homing: Binding multiple NICs to a single IP address
- Previous by thread: Re: Question for multicast
- Next by thread: Re: Question for multicast
- Index(es):
Relevant Pages
|
|