public HttpBackend(IPAddress address, int port, int maxKeepAlives = 100, int backlog = 128, int sessionReadBufferSize = 4096, int sessionReadTimeoutMs = 5000, int sessionWriteTimeoutMs = 5000) { this.port = port; listener = new TcpListener(address, port); this.maxKeepAlives = maxKeepAlives; this.backlog = backlog; this.sessionReadBufferSize = sessionReadBufferSize; sessionReadTimeout = TimeSpan.FromMilliseconds(sessionReadTimeoutMs); sessionWriteTimeout = TimeSpan.FromMilliseconds(sessionWriteTimeoutMs); lifeCycleToken = new LifeCycleToken(); sessionTable = new ConcurrentDictionary <long, HttpSession>(); sessionReads = new ConcurrentDictionary <long, long>(); webSocketSessionTable = new ConcurrentDictionary <long, WebSocketSession>(); sessionExceptionCounters = new CountingDictionary <Type>(); name = $"{GetType().Name}({address}:{port})"; timer = new WaitableTimer(name, TimeSpan.FromSeconds(1), new [] { new WaitableTimer.Job(nameof(CheckSessionReadTimeouts), CheckSessionReadTimeouts) }); }
public BCLHttpListenerBackend(string listenAddress, int listenPort) { ListenOn = string.Format("http://{0}:{1}/", listenAddress, listenPort); name = string.Format("HttpListenerBackend({0}:{1})", listenAddress, listenPort); listener = new HttpListener { IgnoreWriteExceptions = true, }; listener.Prefixes.Add(ListenOn); getContexts = new Semaphore(Environment.ProcessorCount, Environment.ProcessorCount); lifeCycleToken = new LifeCycleToken(); }