コード例 #1
0
        public void Start()
        {
            _layerFactory                 = new OwinHandlerFactory(_parameters.OwinApp, _parameters.OwinCapabilities);
            _ipIsLocalChecker             = new IpIsLocalChecker();
            _connectionAllocationStrategy = _parameters.ConnectionAllocationStrategy;
            var isSsl = _parameters.Certificate != null;

            _layerFactory = new Transport2HttpFactory(_parameters.BufferSize, isSsl, _parameters.ServerHeader, _ipIsLocalChecker, _layerFactory);
            if (isSsl)
            {
                _layerFactory = new SslTransportFactory(_parameters, _layerFactory);
            }
            ListenSocket = new Socket(_parameters.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            var start = DateTime.UtcNow;

            while (true)
            {
                try
                {
                    ListenSocket.Bind(_parameters.EndPoint);
                    break;
                }
                catch when(start + _parameters.RetrySocketBindingTime > DateTime.UtcNow)
                {
                }
                Thread.Sleep(50);
            }
            ListenSocket.Listen(100);
            var initialConnectionCount = _connectionAllocationStrategy.CalculateNewConnectionCount(0, 0);

            AllocatedConnections = initialConnectionCount;
            _blocks.Add(new ConnectionBlock(this, _layerFactory, initialConnectionCount));
        }
コード例 #2
0
ファイル: Server.cs プロジェクト: nobitagamer/Nowin
 public void Start()
 {
     _layerFactory = new OwinHandlerFactory(_parameters.OwinApp, _parameters.OwinCapabilities);
     _ipIsLocalChecker = new IpIsLocalChecker();
     _connectionAllocationStrategy = _parameters.ConnectionAllocationStrategy;
     var isSsl = _parameters.Certificate != null;
     _layerFactory = new Transport2HttpFactory(_parameters.BufferSize, isSsl, _parameters.ServerHeader, _ipIsLocalChecker, _layerFactory);
     if (isSsl)
     {
         _layerFactory = new SslTransportFactory(_parameters, _layerFactory);
     }
     ListenSocket = new Socket(_parameters.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     var start = DateTime.UtcNow;
     while (true)
     {
         try
         {
             ListenSocket.Bind(_parameters.EndPoint);
             break;
         }
         catch when(start + _parameters.RetrySocketBindingTime > DateTime.UtcNow)
         {
         }
         Thread.Sleep(50);
     }
     ListenSocket.Listen(100);
     var initialConnectionCount = _connectionAllocationStrategy.CalculateNewConnectionCount(0, 0);
     AllocatedConnections = initialConnectionCount;
     _blocks.Add(new ConnectionBlock(this, _layerFactory, initialConnectionCount));
 }
コード例 #3
0
ファイル: Server.cs プロジェクト: JuergenGutsch/Nowin
 public void Dispose()
 {
     lock (_newConnectionLock)
     {
         _connectionAllocationStrategy = new FinishingAllocationStrategy();
     }
     ListenSocket.Close();
     foreach (var block in _blocks)
     {
         block.Stop();
     }
 }
コード例 #4
0
ファイル: Server.cs プロジェクト: tonyozr/Nowin
 public void Dispose()
 {
     lock (_newConnectionLock)
     {
         _connectionAllocationStrategy = new FinishingAllocationStrategy();
     }
     ListenSocket.Close();
     foreach (var block in _blocks)
     {
         block.Stop();
     }
 }
コード例 #5
0
ファイル: Server.cs プロジェクト: Bobris/Nowin
        public void Dispose()
        {
            lock (_newConnectionLock)
            {
                _connectionAllocationStrategy = new FinishingAllocationStrategy();
            }

            ListenSocket?.Dispose();

            ConnectionBlock block;
            while (_blocks.TryTake(out block))
            {
                block.Stop();
            }
        }
コード例 #6
0
ファイル: Server.cs プロジェクト: lwliang/doc
        public void Dispose()
        {
            lock (_newConnectionLock)
            {
                _connectionAllocationStrategy = new FinishingAllocationStrategy();
            }

            ListenSocket?.Dispose();

            ConnectionBlock block;

            while (_blocks.TryTake(out block))
            {
                block.Stop();
            }
        }
コード例 #7
0
ファイル: Server.cs プロジェクト: EddieGarmon/Nowin
 public void Start()
 {
     _layerFactory = new OwinHandlerFactory(_parameters.OwinApp, _parameters.OwinCapabilities);
     _ipIsLocalChecker = new IpIsLocalChecker();
     _connectionAllocationStrategy = _parameters.ConnectionAllocationStrategy;
     var isSsl = _parameters.Certificate != null;
     _layerFactory = new Transport2HttpFactory(_parameters.BufferSize, isSsl, _ipIsLocalChecker, _layerFactory);
     if (isSsl)
     {
         _layerFactory = new SslTransportFactory(_parameters.Certificate, _layerFactory);
     }
     ListenSocket = new Socket(_parameters.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     ListenSocket.Bind(_parameters.EndPoint);
     ListenSocket.Listen(100);
     var initialConnectionCount = _connectionAllocationStrategy.CalculateNewConnectionCount(0, 0);
     AllocatedConnections = initialConnectionCount;
     _blocks.Add(new ConnectionBlock(this, _layerFactory, initialConnectionCount));
 }
コード例 #8
0
ファイル: ServerBuilder.cs プロジェクト: slamj1/Nowin
 public ServerBuilder SetConnectionAllocationStrategy(IConnectionAllocationStrategy strategy)
 {
     _connectionAllocationStrategy = strategy;
     return this;
 }
コード例 #9
0
ファイル: ServerBuilder.cs プロジェクト: tonyozr/Nowin
 public ServerBuilder SetConnectionAllocationStrategy(IConnectionAllocationStrategy strategy)
 {
     _connectionAllocationStrategy = strategy;
     return(this);
 }