[Mono-dev] .NET / Mono runtime multi-cast differences.
James P Michels III
james.p.michels at gmail.com
Sun Aug 23 22:20:26 EDT 2009
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------------
More information about the Mono-devel-list
mailing list