【问题标题】:Xamarin says "Allow Multiple Bind To Same Port only allowed on Windows". What do I do?Xamarin 说“只允许在 Windows 上允许多个绑定到同一端口”。我该怎么办?
【发布时间】:2017-07-23 19:12:33
【问题描述】:

我正在尝试在 Xamarin 中将 SocketLite.PCL 与我的 iOS/Android 解决方案一起使用, 但我在运行时收到消息Allow Multiple Bind To Same Port only allowed on Windows

这是什么意思,我该如何解决?

编辑: 我正在使用的示例代码可以在这里找到:https://github.com/1iveowl/SocketLite.PCL

我将以下代码放入应用程序的rotected async override void OnStart(){}

var udpReceived = new UdpSocketReceiver();
await udpReceived.StartListeningAsync(4992, allowMultipleBindToSamePort: true);

var udpMessageSubscriber = udpReceived.ObservableMessages.Subscribe(
    msg =>
    {
        System.Console.WriteLine($"Remote adrres: {msg.RemoteAddress}");
        System.Console.WriteLine($"Remote port: {msg.RemotePort}");

        var str = System.Text.Encoding.UTF8.GetString(msg.ByteData);
        System.Console.WriteLine($"Messsage: {str}");
    },
    ex =>
    {
    // Exceptions received here  
    }
);

编辑 2:

好的,所以将allowMultipleBindToSamePort 设置为false 可以阻止该错误。

现在我收到错误 Address already in use

不过我还是很好奇allowMultipleBindToSamePort 的用途。

【问题讨论】:

  • 你应该把代码贴在你使用库的地方
  • @ganchito55 我更新了问题。

标签: c# ios sockets xamarin udp


【解决方案1】:

正如您在new documentation 中看到的:

重要提示:请注意参数 allowMultipleBindToSamePort 仅适用于 Windows。在其他平台上应该设置为 false

关于不过我还是很好奇allowMultipleBindToSamePort 的用途。

this post上有很好的完整解释,你可以在下面的stackoverflow post阅读更多

【讨论】:

    猜你喜欢
    • 2012-08-20
    • 2023-03-26
    • 2012-04-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 2011-04-13
    • 2016-01-01
    相关资源
    最近更新 更多