private void Connect() { TcpClient clientSocket = new TcpClient(targetHost.Text, (int)targetPort.Value); client = new Client(clientSocket); if (useSSL.Checked == true) { client.ClientSSLAuthentication(); } client.StartReceive(); client.DataReceived += Client_DataReceived; AddLogItem(" !", "Connect"); }
private void OnClientAccept(IAsyncResult iar) { try { TcpClient tcpClient = listener.EndAcceptTcpClient(iar); Client client = new Client(tcpClient); if(certFile.Text.Length > 0) { client.ServerSSLAuthentication(certFile.Text, certPassword.Text); } client.DataReceived += Client_DataReceived; client.DataSent += Client_DataSent; client.ForwardRequest += Client_ForwardRequest; client.StartReceive(); clients.Add(client); ShowClientCount(); listener.BeginAcceptTcpClient(new AsyncCallback(OnClientAccept), listener); } catch (SocketException ex) { AddLogItem(" E", ex.Message); } catch (ObjectDisposedException) { AddLogItem(" !", "Stop listening"); listener = null; } }