private void Listen() { AddStatus("Listener started."); while (true) { TcpClient client = server.AcceptTcpClient(); AddStatus("New Client: " + n.ToString()); AddStatus("Processing..."); TabPage tab = new TabPage("Client " + n.ToString()); n++; TcpClientControl control = new TcpClientControl(); tab.Controls.Add(control); control.Disposed += OnTcpClientControlDispose; Invoke((Action)(() => mainTabControl.TabPages.Add(tab))); control.SetTcpClient(client); AddStatus("Done."); } }
public ClientView(string hostname, ushort port) { InitializeComponent(); Show(); TcpClientControl view = new TcpClientControl(); Controls.Add(view); try { TcpClient client = new TcpClient(hostname, port); view.SetTcpClient(client); view.Disposed += OnDisposed; } catch (SocketException) { MessageBox.Show("Couldn't connect."); Dispose(); } }