internal Connection(IConnectionPool connectionPool, Socket socket, SocketAsyncEventArgs eventArgs, IByteConverter converter)
            : base(socket, converter)
        {
            //set the configuration info
            ConnectionPool = connectionPool;
            Configuration  = ConnectionPool.Configuration;

            //Since the config can be changed on the fly create allocator late in the cycle
            _allocator = Configuration.BufferAllocator(Configuration);

            //create a seae with an accept socket and completed event
            _eventArgs = eventArgs;
            _eventArgs.AcceptSocket = socket;
            _eventArgs.Completed   += OnCompleted;

            //set the buffer to use with this saea instance
            _allocator.SetBuffer(_eventArgs);
        }
Example #2
0
        internal Connection(IConnectionPool connectionPool, Socket socket, IByteConverter converter, BufferAllocator allocator)
            : base(socket, converter)
        {
            ConnectionPool = connectionPool;
            Configuration  = ConnectionPool.Configuration;

            //set the max close attempts so that a connection in use is not disposed
            MaxCloseAttempts = Configuration.MaxCloseAttempts;

            _allocator = allocator;

            //create a seae with an accept socket and completed event
            _eventArgs = new SocketAsyncEventArgs();
            _eventArgs.AcceptSocket = socket;
            _eventArgs.Completed   += OnCompleted;

            //set the buffer to use with this saea instance
            _allocator.SetBuffer(_eventArgs);
            Offset = _eventArgs.Offset;
        }
        public Connection(IConnectionPool connectionPool, Socket socket, IByteConverter converter, BufferAllocator allocator)
            : base(socket, converter)
        {
            ConnectionPool = connectionPool;
            Configuration = ConnectionPool.Configuration;

            //set the max close attempts so that a connection in use is not disposed
            MaxCloseAttempts = Configuration.MaxCloseAttempts;

            _allocator = allocator;

            //create a seae with an accept socket and completed event
            _eventArgs = new SocketAsyncEventArgs();
            _eventArgs.AcceptSocket = socket;
            _eventArgs.Completed += OnCompleted;

            //set the buffer to use with this saea instance
            _allocator.SetBuffer(_eventArgs);
            Offset = _eventArgs.Offset;
        }
Example #4
0
        public Connection(IConnectionPool connectionPool, Socket socket, IByteConverter converter, BufferAllocator allocator)
            : base(socket, converter, allocator)
        {
            ConnectionPool = connectionPool;
            Configuration  = ConnectionPool.Configuration;

            //set the max close attempts so that a connection in use is not disposed
            MaxCloseAttempts = Configuration.MaxCloseAttempts;

            //create a seae with an accept socket and completed event
            _eventArgs = new SocketAsyncEventArgs();
            _eventArgs.AcceptSocket = socket;
            _eventArgs.Completed   += OnCompleted;

            //set the buffer to use with this saea instance
            if (!BufferAllocator.SetBuffer(_eventArgs))
            {
                // failed to acquire a buffer because the allocator was exhausted

                throw new BufferUnavailableException("Unable to allocate a buffer for this connection because the BufferAllocator is exhausted.");
            }
        }