Exemple #1
0
 public PooledBuffer GetBuffer()
 {
     PooledBuffer buffer = null;
     if (!_queues.TryPop(out buffer))
     {
         //no pooled
         buffer = new PooledBuffer(this, new byte[4096], 0, 4096, false);
     }
     Interlocked.Increment(ref _activeCount);
     return buffer;
 }
Exemple #2
0
 internal ConnectStream(Connection connection, ArraySegment<byte> buffer, int offset, int bufferCount, long readCount, bool chunked, HttpRequest request)
 {
     _connection = connection;
     _readBytes = readCount;
     _chunked = chunked;
     if (_chunked)
     {
         _chunkParser = new ChunkParser(connection, buffer, offset, bufferCount);
     }
     else
     {
         _readBuffer = buffer;
         _readOffset = offset;
         _readBufferSize = bufferCount;
     }
     _request = request;
     _pooledBuffer = connection.Buffer;
 }
Exemple #3
0
        public Connection(ServicePoint servicePoint)
        {
            _state = 0;
            _servicePoint = servicePoint;
            _saea = SaeaPool.Default.GetSaea();
            _buffer = BufferPool.Default.GetBuffer();
            _socket = new Socket(servicePoint.HostEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.NoDelay = !servicePoint.UseNagleAlgorithm;

            if (_servicePoint.IsSecured)
            {
                _asyncReadWrite = new SslAsyncReadWrite(servicePoint.Address.Host, _socket, _saea, servicePoint.ClientCertificate, ValidateServerCertificate);
            }
            else
            {
                _asyncReadWrite = new AsyncReadWrite(_socket, _saea);
            }
            
        }
Exemple #4
0
 public void FreeBuffer(PooledBuffer buffer)
 {
     _queues.Push(buffer);
     Interlocked.Decrement(ref _activeCount);
 }