internal HttpListenerContext(HttpConnection cnc)
        {
            this.cnc = cnc;

            request  = new HttpListenerRequest(this);

            response = new HttpListenerResponse(this);
        }
Beispiel #2
0
        void Cleanup(bool close_existing)
        {
            lock (registry)
            {
                if (close_existing)
                {
                    // Need to copy this since closing will call UnregisterContext

                    ICollection keys = registry.Keys;

                    var all = new HttpListenerContext[keys.Count];

                    keys.CopyTo(all, 0);

                    registry.Clear();

                    for (int i = all.Length - 1; i >= 0; i--)
                    {
                        all[i].Connection.Close(true);
                    }
                }

                lock (connections.SyncRoot)
                {
                    ICollection keys = connections.Keys;

                    var conns = new HttpConnection[keys.Count];

                    keys.CopyTo(conns, 0);

                    connections.Clear();

                    for (int i = conns.Length - 1; i >= 0; i--)
                    {
                        conns[i].Close(true);
                    }
                }
                lock (ctx_queue)
                {
                    var ctxs = (HttpListenerContext[])ctx_queue.ToArray(typeof(HttpListenerContext));

                    ctx_queue.Clear();

                    for (int i = ctxs.Length - 1; i >= 0; i--)
                    {
                        ctxs[i].Connection.Close(true);
                    }
                }

                lock (wait_queue)
                {
                    Exception exc = new ObjectDisposedException("listener");

                    foreach (ListenerAsyncResult ares in wait_queue)
                    {
                        ares.Complete(exc);
                    }

                    wait_queue.Clear();
                }
            }
        }
Beispiel #3
0
 internal void RemoveConnection(HttpConnection cnc)
 {
     connections.Remove(cnc);
 }
Beispiel #4
0
 internal void AddConnection(HttpConnection cnc)
 {
     connections[cnc] = cnc;
 }
Beispiel #5
0
        static void OnRead(IAsyncResult ares)
        {
            HttpConnection cnc = (HttpConnection)ares.AsyncState;

            cnc.OnReadInternal(ares);
        }