Exemple #1
0
        void OnConnection(Tcp client, Exception error)
        {
            client.UserToken = this;

            EndPointListener epl = this;

            epl.timer.Change(1, Timeout.Infinite);

            ProcessAccept(client);
        }
 public static void RemoveEndPoint(EndPointListener epl, IPEndPoint ep)
 {
     lock (ip_to_endpoints) {
         // Dictionary<int, EndPointListener> p
         Hashtable p = null;
         p = (Hashtable)ip_to_endpoints [ep.Address];
         p.Remove(ep.Port);
         if (p.Count == 0)
         {
             ip_to_endpoints.Remove(ep.Address);
         }
         epl.Close();
     }
 }
        static void RemovePrefixInternal(string prefix, HttpListener listener)
        {
            ListenerPrefix lp = new ListenerPrefix(prefix);

            if (lp.Path.IndexOf('%') != -1)
            {
                return;
            }

            if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1)
            {
                return;
            }

            EndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure);

            epl.RemovePrefix(lp, listener);
        }
        static void AddPrefixInternal(string p, HttpListener listener)
        {
            ListenerPrefix lp = new ListenerPrefix(p);

            if (lp.Path.IndexOf('%') != -1)
            {
                throw new HttpListenerException(400, "Invalid path.");
            }

            if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1)              // TODO: Code?
            {
                throw new HttpListenerException(400, "Invalid path.");
            }

            // listens on all the interfaces if host name cannot be parsed by IPAddress.
            EndPointListener epl = GetEPListener(lp.Host, lp.Port, listener, lp.Secure);

            epl.AddPrefix(lp, listener);
        }
        public HttpConnection(Tcp sock, Nobodyshot.Net.ThreadLibuv thread, EndPointListener epl, bool secure, X509Certificate2 cert, AsymmetricAlgorithm key)
        {
            this.state = 1;

            try
            {
                if (((IPEndPoint)sock.GetLocalEndPoint()).Port == 0)
                {
                    Console.WriteLine("0 ep");
                }
            }
            catch
            {
                Console.WriteLine("Bad ep");
            }


            //sock.Blocking = false;

            this.sock   = sock;
            this.thread = thread;
            this.epl    = epl;
            this.secure = secure;
            this.key    = key;


            if (secure == false)
            {
                stream = new MemoryStream();
            }

            timer = new System.Threading.Timer(OnTimeout, null, Timeout.Infinite, Timeout.Infinite);


            Init();
        }