c# - 在非管理员帐户上使用多个 PGM 监听套接字获取访问异常

标签 c# .net sockets multicast pgm-protocol

以下代码适用于管理员帐户,但对于非管理员帐户,它会打印两次成功然后抛出 System.Net.Sockets.SocketException (0x80004005):尝试以其禁止的方式访问套接字访问权限。任何人都知道这是为什么?

仅供引用,这里的实际用例是多个应用程序使用相同的 PGM 地址和套接字。推送(通过多播)实时更新。这不是由我们自己的库引起的概念证明。

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();
    }

最佳答案

好吧,我终于从微软那里得到了关于这个的消息,而且没有解决方法。

I was able to find the line where your request was denied.

[0] 22E8.1554::08/15/2012-10:05:19.015 [sys] address_c491 PgmCreateAddress() - PgmCreateAddress: ERROR -- Non-admin user trying to open 2+1 handle for IP:Port=

With a little code review, I was able to verify that only three principals are granted access, and they are Administrators, LocalService and NetworkService. Apart from being a member of Administrators, there is no workaround.

I know this wasn’t the answer you wanted to hear, but at least now you have a confirmed answer.

关于c# - 在非管理员帐户上使用多个 PGM 监听套接字获取访问异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11747545/

相关文章:

c# - 将值与数组进行比较并获得最接近它的值

python - 如何以智能方式将UDP客户端消息发送到UDP服务器解析消息

c# - 在 Win 表单应用程序中保留表单数据

c# - Reflection Get List<> from List<T>(来自通用容器类型的容器类型)

c# - 如何使用 .net 减小从 ssrs 生成的 pdf 文件的大小

.net - 将 MStest(从 XML)的结果发送给我的经理

c# - 如何在自定义 NuGet 包中为不同版本的 .NET 框架指定不同的依赖项?

需要 C# 简单 DataSocket 示例

c - 如何获取已接受套接字的目标地址?

c# - 如何获取字符串(url)的一部分?