Exemplo n.º 1
0
        /// <summary>
        /// Close and release socket.
        /// </summary>
        private void Close()
        {
            lock (this)
            {
                if (Socket == null)
                {
                    return;
                }

                try
                {
                    HTTPContextManager.Unregister(this);
                    Socket.Disconnect(true);
                    Socket.Close();
                    Socket = null;
                    Stream.Close();
                    Stream.Dispose();
                    Stream = null;
                    MessageFactoryContext.RequestCompleted          -= OnRequest;
                    MessageFactoryContext.ContinueResponseRequested -= On100Continue;
                    MessageFactoryContext.Reset();
                }
                catch (Exception err)
                {
                    _logger.Warning("Failed to close context properly.", err);
                }
            }
            Disconnected(this, EventArgs.Empty);
        }
Exemplo n.º 2
0
 private void OnConnectionTimeout(object state)
 {
     HTTPContextManager.Unregister(this);
     _logger.Info("Keep-Alive timeout");
     Disconnect();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Disconnect context.
 /// </summary>
 public void Disconnect()
 {
     HTTPContextManager.Unregister(this);
     Close();
 }