The following Code works fine for an admin account but for an non admin account it prints success twice then throws an System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions. Anyone have any insight to why this is?
FYI the actual use case here is multiple applications using the same PGM Address and Socket. to push (via multicast) real time updates. This Proof of concept that this isnt caused by our own libraries.
class Program {
static void Main(string[] args) {
IPAddress ipAddr = IPAddress.Parse("239.0.0.2");
IPEndPoint end = new IPEndPoint(ipAddr, 40002);
Socket[] _sockets = new[] {
new Socket(AddressFamily.InterNetwork, SocketType.Rdm, (ProtocolType)113 ),
new Socket(AddressFamily.InterNetwork, SocketType.Rdm, (ProtocolType)113 ),
new Socket(AddressFamily.InterNetwork, SocketType.Rdm, (ProtocolType)113 )
};
foreach (var socket in _sockets)
{
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
socket.Bind(end);
Console.WriteLine("Success");
}
Console.ReadLine();
}
}
Well I finally got word from Microsoft on this and there is no workaround.