try
{
connectButton.IsEnabled = false;
await _socket.ConnectAsync(new HostName(ipConnect.Text), "13928");
}
catch(ArgumentException)
{
MessageDialog dlg = new MessageDialog("Неверный IP адрес");
await dlg.ShowAsync();
}
catch
{
MessageDialog dlg = new MessageDialog("Не удалось подключиться");
await dlg.ShowAsync();
}
sr = new StreamReader(_socket.InputStream.AsStreamForRead());
sw = new StreamWriter(_socket.OutputStream.AsStreamForWrite());
string opAnswer = sr.ReadLine();
服务器使用StreamSocketListener在PC上使用Windows 10 UI应用程序。 等待服务器响应10秒后,opAnswer - null和socket关闭。