[Mono-list] Joining multicast groups with Socket

markohrastovec marko.hrastovec at gmail.com
Fri May 22 03:44:04 EDT 2009


I have had a strange problem with mono.

I am using Socket class to listen some UDP traffic and that socket must join
multicast.

The line for joining multicast looks like this:
udpSocket.SetSocketOption (SocketOptionLevel.IP,
SocketOptionName.AddMembership, new MulticastOption (ipMulticast,
ipAddress));

I have tested that on a computer in a development environment and it worked
fine. When I moved the computer to another network some strange problems
occured.

I got the following messages when I tried to run this program as a service:
May 21 09:23:11 xxx mono: yyy.exe: Exception has been thrown by the target
of an invocation.
May 21 09:23:11 xxx mono: yyy.exe: Network subsystem is down.

I found out that the error occured when computer wanted to join multicast
with the line of code I have provided at the beginning. When I put the
computer in the development network it worked OK again. Then I started to
analyze what is the difference and found out the following. The development
network has default gateway defined and the other network has not. The
reason is that network is closed an no traffic does need to go in or out of
that network. That is why I didn't provide default gateway in network
settings. Then I put some dummy default gateway into network configuration
and all started to work fine.

I am not sure if it is OK to work that way. I think joining multicast group
should work with no default gateway too. It is true that multicast IP I was
using is outside of the network (224.1.1.1) because all multicast adresses
have reserved IP space out of any other network. But adding a default
gateway that does not exist is not a sensible solution for me.

I am writing this to help anyone that may encounter similar problems. I also
hope some mono developers will take a look at it and maybe correct it in the
future releases. I didn't test that in .NET & Windows since I don't use
multicast there. I was using mono 2.4 on Centos 5.3.
-- 
View this message in context: http://www.nabble.com/Joining-multicast-groups-with-Socket-tp23665993p23665993.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list