//-----------------------------------------------------------------------------------Connection part private async void MenuItemCreate_Click(object sender, RoutedEventArgs e) { var dlg = new CreateServerDialog(); var result = dlg.ShowDialog(); if (result == null || result.Value == false) { return; } btnCreate.IsEnabled = false; btnConnect.IsEnabled = false; var localEP = new IPEndPoint(dlg.IPAddress, dlg.Port); listener = new TcpListener(localEP); listener.Start(); client = await listener.AcceptTcpClientAsync(); CreateReceiveTask(); listener.Stop(); }
private async void MenuItemConnect_Click(object sender, RoutedEventArgs e) { var dlg = new CreateServerDialog() { Title = "Connect to server" }; var result = dlg.ShowDialog(); if (result == null || result.Value == false) { return; } var tcpClient = new TcpClient(AddressFamily.InterNetwork); await tcpClient.ConnectAsync(dlg.IPAddress, dlg.Port); if (tcpClient.Connected) { client = tcpClient; CreateReceiveTask(); } btnCreate.IsEnabled = false; btnConnect.IsEnabled = false; }