Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the ServerSocket.
        /// </summary>
        /// <param name="settings">The settings to use with this ServerSocket.</param>
        public ServerSocket(ServerSocketSettings settings)
        {
            _settings = settings;

            _bufferManager =
                new BufferManager(
                    (_settings.BufferSize*_settings.NumOfSaeaForRec) + (_settings.BufferSize*_settings.NumOfSaeaForSend),
                    _settings.BufferSize);
            _poolOfAcceptEventArgs = new SocketAsyncEventArgsPool(_settings.MaxSimultaneousAcceptOps);
            _poolOfRecEventArgs = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForRec);
            _poolOfSendEventArgs = new SocketAsyncEventArgsPool(_settings.NumOfSaeaForSend);

            _maxConnectionsEnforcer = new SemaphoreSlim(_settings.MaxConnections, _settings.MaxConnections);
            _maxSaeaSendEnforcer = new SemaphoreSlim(_settings.NumOfSaeaForSend, _settings.NumOfSaeaForSend);
            _maxAcceptOpsEnforcer = new SemaphoreSlim(_settings.MaxSimultaneousAcceptOps,
                                                     _settings.MaxSimultaneousAcceptOps);
        }