[Mono-dev] .NET / Mono runtime multi-cast differences.

James P Michels III james.p.michels at gmail.com
Mon Aug 24 08:54:02 EDT 2009

The central problem is described in the sentence "Unless the Socket.Bind
operation is modified to bind to a different end
point based on the runtime, no packets will be received."

The meaning of listenChannel and listenEndpoint can be inferred from
their use in subsequent statements, but for sake of clarity, I should
have explained them better.

listenChannel = An end point containing the multicast address / port
combination which you are interested in joining / subscribing to.
listenEndpoint = An end point containing the interface address /
multicast port combination of the network interface on which you would
like to receive the packets.


Alan McGovern wrote:
> Hi,
> Unless I'm missing something, you haven't actually described what the
> problem is. Nor have you mentioned what exactly happens on windows,
> what happens on linux and what you actually expected to happen. Your
> example also appears to be missing information which might help figure
> out what issue it is you're seeing, what are listenChannel and
> listenEndpoint?
> Alan.
> On Mon, Aug 24, 2009 at 3:20 AM, James P Michels III
> <james.p.michels at gmail.com <mailto:james.p.michels at gmail.com>> wrote:
>     I have observed a difference in behavior between the Mono runtime and
>     .NET runtime with respect to multi-cast support.
>     Unless the Socket.Bind operation is modified to bind to a
>     different end
>     point based on the runtime, no packets will be received. The
>     workaround
>     that I am using is shown in the attached code section.
>     I took a look at Mono's source code. Additionally, I wrote a short C
>     program with the equivalent functionality. The C version for Linux
>     exhibits the same behavior. It is my impression that the behavior
>     is due
>     to differences between the Windows socket implementation and the Linux
>     socket implementation. It is also my impression that these differences
>     are being realized by both the .NET and Mono runtime which ultimately
>     consume them.
>     I have 2 questions.
>     1) Am I wrong? Is there a runtime agnostic way to do this? (Binding to
>     IPAddress.Any does not work on Windows to my knowledge)
>     2) If I am not wrong, what steps, if any, should be taken to resolve
>     these differences?
>     Thanks
>     Jim
>     ---------begin code sample------------
>            listenSocket = new Socket(AddressFamily.InterNetwork,
>     SocketType.Dgram, ProtocolType.Udp);
>            listenSocket.SetSocketOption(SocketOptionLevel.Socket,
>     SocketOptionName.ReuseAddress, true);
>            if (IsMonoRuntime())
>            {
>                listenSocket.Bind(listenChannel);
>            }
>            else
>            {
>                listenSocket.Bind(listenEndpoint);
>            }
>            listenSocket.SetSocketOption(SocketOptionLevel.IP,
>     SocketOptionName.MulticastInterface,
>     listenInterface.GetAddressBytes());
>            listenSocket.SetSocketOption(SocketOptionLevel.IP,
>     SocketOptionName.AddMembership, new
>     MulticastOption(listenChannel.Address, listenInterface));
>     ---------end code sample------------
>     _______________________________________________
>     Mono-devel-list mailing list
>     Mono-devel-list at lists.ximian.com
>     <mailto:Mono-devel-list at lists.ximian.com>
>     http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list