// Main method in class Transfer public async void ProcessAsync(TcpClient browser) { try { using (browser) { using (TcpClient server = new TcpClient()) { await server.ConnectAsync(_remoteIpAddress, _remotePort); Console.WriteLine($"Remote connected: {server.Client.RemoteEndPoint}"); if (await this.HandshakeAsync(browser.GetStream(), server.GetStream())) { await this.RunTransferringAsync(browser.GetStream(), server.GetStream()); } } } } catch (Exception ex) { StackFrame sf = new StackFrame(true); BaseFunctions.HandleException(ex, sf.GetFileName(), sf.GetFileLineNumber()); } }