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)); }
public void Dispose() { lock (_newConnectionLock) { _connectionAllocationStrategy = new FinishingAllocationStrategy(); } ListenSocket.Close(); foreach (var block in _blocks) { block.Stop(); } }
public void Dispose() { lock (_newConnectionLock) { _connectionAllocationStrategy = new FinishingAllocationStrategy(); } ListenSocket?.Dispose(); ConnectionBlock block; while (_blocks.TryTake(out block)) { block.Stop(); } }
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)); }
public ServerBuilder SetConnectionAllocationStrategy(IConnectionAllocationStrategy strategy) { _connectionAllocationStrategy = strategy; return this; }
public ServerBuilder SetConnectionAllocationStrategy(IConnectionAllocationStrategy strategy) { _connectionAllocationStrategy = strategy; return(this); }