public void AddConnection(TcpClientConnection conn) { lock (_syncRoot) { _pool.Add(conn); } }
public void RemoveConnection(TcpClientConnection conn) { lock (_syncRoot) { _pool.Remove(conn); } }
public async Task <TcpClientConnection> GetNewConnection(bool addToPool) { var exceptions = new List <Exception>(); foreach (var tcpRemote in _remotes) { try { var conn = await TcpClientConnection.ConnectAsync(tcpRemote.Host, tcpRemote.Port); if (addToPool) { _pool.Add(conn); } return(conn); } catch (Exception e) { exceptions.Add(e); } } throw new AggregateException("Unable to connect to any of the specified hosts", exceptions); }