【发布时间】: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