public TcpTestConnectionContext(ControlConnectionContext control, NetworkStream testStream, TcpClient testClient, int testDurationSeconds) { this.control = control; this.testStream = testStream; this.testClient = testClient; this.testDurationSeconds = testDurationSeconds; this.bufferToWrite = StaticRandom.NextBytes(500000); this.bufferToRead = new byte[500000]; }
public static void OpenTestConnection(ControlConnectionContext control, int testDurationSeconds) { TcpClient testClient = null; try { IPEndPoint remoteEP = (IPEndPoint)control.client.Client.RemoteEndPoint; testClient = new TcpClient(); TcpTestConnectionContext context = new TcpTestConnectionContext(control, null, testClient, testDurationSeconds); testClient.BeginConnect(remoteEP.Address, remoteEP.Port, EndConnect, context); } catch { testClient?.Close(); } }