我试图从本地SocketServer读取消息。但是connectasync方法总是失败:
private async void ConnectToServer()
{
try
{
_socket = new StreamSocketListener();
_socket.ConnectionReceived += Socket_ConnectionReceived;
await _socket.BindEndpointAsync(new HostName("192.168.1.51"), "9090");
}
catch (Exception ex)
{
throw;
}
}
错误类型为System.Runtime.InteropServices.COMException
,邮件为The requested address is not valid in its context
。
我无法弄清楚可能出现的问题,因为我还在PackageManifest中声明了所有必需的功能
<Capabilities>
<Capability Name="privateNetworkClientServer" />
<Capability Name="internetClientServer" />
</Capabilities>