UDP地址已在使用Xamarin

时间:2017-07-24 02:26:07

标签: ios sockets xamarin xamarin.ios udp

我试图在Xamarin中使用SocketLite.PLC创建UDP服务器。

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

我的代码如下所示:

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

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

1 个答案:

答案 0 :(得分:0)

我会尝试这样的事情:

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

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

相关问题