Esempio n. 1
0
        private SocketAsyncEventArgsPool mSocketPool; //<! Pool of reusable SocketAsyncEventArgs objects for accept, read, and write operations

        #endregion Fields

        #region Constructors

        public AsyncServer(ServerHost host, int numConnections, int receiveBufferSize)
        {
            mContext = host;
            allDone = new Mutex();

            mNumConnectedSockets = 0;
            mNumConnections = numConnections;
            mReceiveBufferSize = receiveBufferSize;

            // Allocate buffers so that the maximum number of sockets can each have one simultaneous read and write
            int totalBytes = receiveBufferSize * numConnections * opsToPreAlloc;
            mBufferManager = new BufferManager(totalBytes, receiveBufferSize);

            mSocketPool = new SocketAsyncEventArgsPool(numConnections);
            mMaxNumberAcceptedClients = new Semaphore(numConnections, numConnections);

            Init();
        }
Esempio n. 2
0
        public AsyncServer(ServerHost host, int numConnections, int receiveBufferSize)
        {
            mContext = host;
            allDone  = new Mutex();

            mNumConnectedSockets = 0;
            mNumConnections      = numConnections;
            mReceiveBufferSize   = receiveBufferSize;

            // Allocate buffers so that the maximum number of sockets can each have one simultaneous read and write
            int totalBytes = receiveBufferSize * numConnections * opsToPreAlloc;

            mBufferManager = new BufferManager(totalBytes, receiveBufferSize);

            mSocketPool = new SocketAsyncEventArgsPool(numConnections);
            mMaxNumberAcceptedClients = new Semaphore(numConnections, numConnections);

            Init();
        }