Multicast

  • Thread starter Thread starter Jayme.Pechan
  • Start date Start date
J

Jayme.Pechan

I was working on a multicast client and ran into a possible problem. Here
is the code...

udpClient = new UdpClient(4000);
udpClient.JoinMulticastGroup(IPAddress.Parse("224.1.1.1"));
udpClient.BeginReceive(new AsyncCallback(DoUDPReceive), this);

My concern is that it seems to make exclusive use of port 4000 so I worry
that in a Citrix environment, it would fail with an AddressAlreadyInUse
exception like it does if you run two instances locally. Unfortunatelly it
doesn't seem to take the ExclusiveUseAddress = false option either. Even if
I use a bind instead of the constructor, it seems to ignore the property and
give me the same error.

Does anyone know how to resolve this issue properly? Thanks.

Jayme
 
[...]
My concern is that it seems to make exclusive use of port 4000 so I
worry that in a Citrix environment, it would fail with an
AddressAlreadyInUse exception like it does if you run two instances
locally.

I admit, I haven't used multicast much in my network programming, but I
was under the impression that this is a fundamental limitation of
multicast using TCP/IP. That is, the client has to bind to the multicast
port to receive multicast datagrams for that group, and you can only have
one client bound to a given adapter/port combination.

Some possible work-arounds (not C# or .NET specific):

* Multiple network adapters would allow multiple clients to bind to
the same port, but on different adapters (IP addresses)

* Have a per-network-adapter proxy that clients can use...the proxy
would subscribe to the multicast, and clients would subscribe indirectly
through the proxy.

I could be wrong about the limitation, but I did just take a look at this
recently and I'm pretty sure I came away thinking the same thing as you,
that you simply can't have more than one multicast client for a given
group on the same network adapter.
Unfortunatelly it doesn't seem to take the ExclusiveUseAddress = false
option either. Even if I use a bind instead of the constructor, it
seems to ignore the property and give me the same error.

Just FYI: you would actually be more interested in the ReuseAddress socket
option. The ExclusiveUseAddress _prevents_ address reuse, but does not
specifically enable it. It's used to override the ReuseAddress option's
behavior, in the event that you don't want any other applications reusing
the socket address you're using.

However, ReuseAddress doesn't allow multiple sockets to receive the same
data anyway. It just allows a new socket to reuse an address that is
nominally already taken. It will take over receipt of data, and the
previously existing socket will no longer get data (though it will be able
to send). This potential for a denial-of-service is, I believe, why
ExclusiveUseAddress exists. :)

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top