void CreateContextPool(int maxNumberOfConnnections)
        {
            int recvSize = 1024 * 2;
            int sendSize = 1024 * 2;

            _bufferMan = new BufferManager((recvSize + sendSize) * maxNumberOfConnnections, (recvSize + sendSize));
            //Allocate memory for buffers. We are using a separate buffer space for
            //receive and send, instead of sharing the buffer space, like the Microsoft
            //example does.
            _contextPool = new SharedResoucePool <HttpsContext>(maxNumberOfConnnections);
            //------------------------------------------------------------------
            //It is NOT mandatory that you preallocate them or reuse them. But, but it is
            //done this way to illustrate how the API can
            // easily be used to create ***reusable*** objects to increase server performance.
            //------------------------------------------------------------------
            //connection session: socket async = 1:1
            for (int i = maxNumberOfConnnections - 1; i >= 0; --i)
            {
                var context = new HttpsContext(this,
                                               recvSize,
                                               sendSize);
                context.CreatedFromPool = true;
                context.BindReqHandler(_reqHandler); //client handler

                _contextPool.Push(context);
            }
        }
        public void Start()
        {
            if (_isRunning)
            {
                return;
            }
            //------------------------------
            try
            {
                //------------------------------
                int maxNumberOfConnections  = 500;
                int excessSaeaObjectsInPool = 200;
                int backlog = 100;
                int maxSimultaneousAcceptOps = 100;

                var setting = new NewConnListenerSettings(maxNumberOfConnections,
                                                          excessSaeaObjectsInPool,
                                                          backlog,
                                                          maxSimultaneousAcceptOps,
                                                          new IPEndPoint(_localOnly ? IPAddress.Loopback : IPAddress.Any, _port));//check only local host or not

                CreateContextPool(maxNumberOfConnections);
                _newConnListener = new NewConnectionListener(setting,
                                                             clientSocket =>
                {
                    //when accept new client

                    int recvSize         = 1024 * 2;
                    int sendSize         = 1024 * 2;
                    HttpsContext context = new HttpsContext(this, recvSize, sendSize);
                    context.BindReqHandler(_reqHandler);     //client handler
#if DEBUG
                    context.dbugForHttps = true;
#endif


                    context.BindSocket(clientSocket); //*** bind to client socket
                                                      //for ssl -> cert must not be null
                    context.StartReceive(_serverCert);
                    //TODO::
                    //USE https context from Pool????
                    //{
                    //    HttpsContext context = _contextPool.Pop();
                    //    context.BindSocket(clientSocket); //*** bind to client socket
                    //    context.StartReceive(UseSsl ? _serverCert : null);
                    //}
                });
                //------------------------------


                //start web server
                _isRunning = true;
                _newConnListener.StartListening();
            }
            catch (Exception ex)
            {
            }
        }