views:

244

answers:

1

I'm trying to have my ASP.NET app listen for multicast UDP broadcasts. Unfortunately, I seem to be stuck in a bind due to permissions/api issues.

The problem is that I need to allow multiple instances of an application to listen to the same IP/Port since multiple spin-ups of the ASP.NET application will occur. To do this, the SocketOptionName.ReuseAddress must be set to true. The problem is that this requires administrative privileges that my ASP.NET app should not have.

Here's the code:

public static void Listen(int port)
{
   var groupAddress = IPAddress.Parse("224.10.10.10");
   var endPoint = new IPEndPoint(groupAddress, port);
   var client = new UdpClient();

   client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
   client.Client.Bind(new IPEndpoint(IPAddress.Any, port)); // Error thrown here       
   client.JoinMulticastGroup(groupAddress);       

   var udpState = new UdpState() { Client = client, EndPoint = endPoint };
   client.BeginReceive(OnMessageReceived, udpState); // OnMessageReceived code omitted
}
A: 

Unfortunately, it seems as though this isn't possible without administrative rights. If anyone has any other ideas, I'd love to hear them.

Brian Vallelunga