예제 #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)
        {
            this.Settings = settings;

            this.BufferManager = new BufferManager((this.Settings.BufferSize * this.Settings.NumOfSaeaForRec) + (this.Settings.BufferSize * this.Settings.NumOfSaeaForSend),
                this.Settings.BufferSize);
            this.PoolOfAcceptEventArgs = new SocketAsyncEventArgsPool(this.Settings.MaxSimultaneousAcceptOps);
            this.PoolOfRecEventArgs = new SocketAsyncEventArgsPool(this.Settings.NumOfSaeaForRec);
            this.PoolOfSendEventArgs = new SocketAsyncEventArgsPool(this.Settings.NumOfSaeaForSend);

            this.MaxConnectionsEnforcer = new SemaphoreSlim(this.Settings.MaxConnections, this.Settings.MaxConnections);
            this.MaxSaeaSendEnforcer = new SemaphoreSlim(this.Settings.NumOfSaeaForSend, this.Settings.NumOfSaeaForSend);
            this.MaxAcceptOpsEnforcer = new SemaphoreSlim(this.Settings.MaxSimultaneousAcceptOps, this.Settings.MaxSimultaneousAcceptOps);
        }
예제 #2
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)
        {
            this.Settings = settings;

            this.BufferManager = new BufferManager((this.Settings.BufferSize * this.Settings.NumOfSaeaForRec) + (this.Settings.BufferSize * this.Settings.NumOfSaeaForSend),
                                                   this.Settings.BufferSize);
            this.PoolOfAcceptEventArgs = new SocketAsyncEventArgsPool(this.Settings.MaxSimultaneousAcceptOps);
            this.PoolOfRecEventArgs    = new SocketAsyncEventArgsPool(this.Settings.NumOfSaeaForRec);
            this.PoolOfSendEventArgs   = new SocketAsyncEventArgsPool(this.Settings.NumOfSaeaForSend);

            this.MaxConnectionsEnforcer = new SemaphoreSlim(this.Settings.MaxConnections, this.Settings.MaxConnections);
            this.MaxSaeaSendEnforcer    = new SemaphoreSlim(this.Settings.NumOfSaeaForSend, this.Settings.NumOfSaeaForSend);
            this.MaxAcceptOpsEnforcer   = new SemaphoreSlim(this.Settings.MaxSimultaneousAcceptOps, this.Settings.MaxSimultaneousAcceptOps);
        }