Пример #1
0
 public TcpConnection(HostConnectionPool pool, ReusableTcpClient client)
 {
     _pool        = pool;
     _client      = client;
     _stream      = new BufferedStream(client.GetStream());
     _controlTime = DateTime.Now;
     _buffer      = new byte[TcpMessageIO.DefaultStreamBufferSize];
 }
Пример #2
0
        public static TcpConnection GetConnection(string host, int port)
        {
            HostConnectionPool hostPool;

            lock (_pools)
            {
                string key = host + ":" + port;
                hostPool = (HostConnectionPool)_pools[key];
                if (hostPool == null)
                {
                    hostPool    = new HostConnectionPool(host, port);
                    _pools[key] = hostPool;
                }
            }

            return(hostPool.GetConnection());
        }