Ejemplo n.º 1
0
        private void SetupClient()
        {
            if (client != null)
                client.Disconnect();

            var socket = GetSocket();
            socket.Connect();

            protocol = new KestrelProtocol(socket);

            client = new KestrelClient(protocol);
        }
Ejemplo n.º 2
0
        private KestrelClient CreateClient()
        {
            WrappedSocket socket = GetSocket();

            var protocol = new KestrelProtocol(socket);

            var client = new KestrelClient(protocol);

            client.Connect();

            return client;
        }
Ejemplo n.º 3
0
 protected KestrelClient CreateServer(IPEndPoint endpoint)
 {
     var socket = new WrappedSocket(endpoint, _configuration.SendReceiveTimeout);
     var protocol = new KestrelProtocol(socket);
     var server = new KestrelClient(protocol);
     return server;
 }
Ejemplo n.º 4
0
 public ServerWrapper(ServerPool pool, KestrelClient client)
 {
     _pool = pool;
     Client = client;
 }
Ejemplo n.º 5
0
        public void Release(KestrelClient client)
        {
            if (client.IsTainted || ! client.IsAlive || _isDisposed)
            {
                using (client)
                {
                    client.Disconnect();
                }
                return;
            }

            // client should be ok, return it to the pool
            var endpoint = client.Protocol.Socket.EndPoint;
            var serverInfo = GetServerInfoByEndPoint(endpoint);
            lock (serverInfo)
            {
                if (serverInfo.Queue.Count > this._configuration.MaxConnections)
                {
                    using (client)
                    {
                        client.Disconnect();
                    }
                }
                else
                {
                    serverInfo.Queue.Enqueue(client);
                }
            }
        }