/// <summary> /// Initializes the server by preallocating reusable buffers and context objects. These objects do not /// need to be preallocated or reused, by is done this way to illustrate how the API can easily be used /// to create reusable objects to increase server performance. /// </summary> private void Init() { string message = string.Format("Listener on {0}, MessageTransport = {1}, BufferManager = {2}", Configuration.EndPoint, MessageTransport.GetType().Name, _compressionBufferManager.GetType().Name); Logger.Info(message, LogType.System); Console.WriteLine(message); // preallocate pool for (int i = 0; i < this._configuration.ConnectionCapacity; i++) { SocketAsyncEventArgs disconnectSocketEventArg = new SocketAsyncEventArgs { DisconnectReuseSocket = true }; disconnectSocketEventArg.Completed += DisconnectSocketCompletedHandler; this._disconnectSocketArgsPool.Put(disconnectSocketEventArg); this._clientConnectionInfoPool.Put(new ClientConnectionInfo()); } }