【问题标题】:UDP Address already in use XamarinUDP 地址已在使用 Xamarin
【发布时间】:2017-07-24 02:26:06
【问题描述】:

我正在尝试在 Xamarin 中使用 SocketLite.PLC 创建一个 UDP 服务器。

运行 iOS 应用时,无论我尝试监听哪个端口,都会收到错误 Address already in use。

我的代码如下所示:

var udpReceived = new UdpSocketReceiver();
await udpReceived.StartListeningAsync(6932, allowMultipleBindToSamePort: false);

为什么会发生这种情况,我该如何解决?

【问题讨论】:

  • 我切换了库。我用的那个没用而且有问题。

标签: ios sockets xamarin xamarin.ios udp


【解决方案1】:

我会尝试这样的事情:

using (UdpSocketReceiver udpReceived = new UdpSocketReceiver())
{     
     //operations
     await udpReceived.StartListeningAsync(6932, allowMultipleBindToSamePort: false);
     udpReceived.Close();
}

我打赌这与我发现的关于 xamarin 和 TcpListener (which can be found here) 的线程类似。

【讨论】:

  • 不幸的是,Close() 不存在,但StopListening() 存在。我仍然得到同样的错误。是不是我需要在Entitlements.plist 中添加一些内容以允许使用 UDP 连接?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-05
  • 2016-09-22
  • 1970-01-01
  • 1970-01-01
  • 2014-11-03
  • 2018-06-07
  • 2021-08-26
相关资源
最近更新 更多