private void DisposeSocket() { if (_tcpConnection != null) { _tcpConnection.Dispose(); _tcpConnection = null; } }
public void TestManyInvalidConnectDisconnect() { var status = _application.Status; int before = status.get_SessionCount(eSessionType.eSTSMTP); int count = 1000; var connections = new List<TcpConnection>(); for (int i = 0; i < count; i++) { var conn = new TcpConnection(false); conn.Connect(25); connections.Add(conn); } RetryHelper.TryAction(() => { int connCount = status.get_SessionCount(eSessionType.eSTSMTP); Assert.GreaterOrEqual(connCount, count); }, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(1)); foreach (var conn in connections) conn.Dispose(); RetryHelper.TryAction(() => { int after = status.get_SessionCount(eSessionType.eSTSMTP); Assert.GreaterOrEqual(before, after); }, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(1)); }