Esempio n. 1
0
 public void RemoveConnection(TcpClientConnection conn)
 {
     lock (_syncRoot)
     {
         _pool.Remove(conn);
     }
 }
Esempio n. 2
0
 public void AddConnection(TcpClientConnection conn)
 {
     lock (_syncRoot)
     {
         _pool.Add(conn);
     }
 }
Esempio n. 3
0
        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);
        }