static void Main(string[] args) { pipeLineDeph = int.Parse(args.FirstOrDefault(f => f.StartsWith("-p"))?.Substring(2) ?? "16"); int connections = int.Parse(args.FirstOrDefault(f => f.StartsWith("-c"))?.Substring(2) ?? "1024"); Console.WriteLine("RioSharp http server"); Console.WriteLine("Optimizing for " + connections + " connections"); Console.WriteLine("Optimizing for pipeline depth of: " + pipeLineDeph); sendPool = new RioFixedBufferPool(10 * connections, 256 * pipeLineDeph); recivePool = new RioFixedBufferPool(10 * connections, 256 * pipeLineDeph); listener = new RioTcpListener(sendPool, recivePool, (uint)connections); currentSegment = listener.PreAllocateWrite(GetResponse()); responseBytes = GetResponse(); //Task.Run(async () => //{ // while (true) // { // UpdateResponse(); // await Task.Delay(60000); // } //}); listener.OnAccepted = new Action<RioSocket>(s => ThreadPool.QueueUserWorkItem(o => Servebuff((RioSocket)o), s)); listener.Listen(new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), 5000), 1024 * connections); Console.WriteLine("Listening on : http://localhost:5000"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); listener.Dispose(); }
static void Main(string[] args) { clientPool = new RioTcpClientPool(new RioFixedBufferPool(100, 100), new RioFixedBufferPool(10, 100), 4096); listener = new RioTcpListener(new RioFixedBufferPool(100, 100), new RioFixedBufferPool(100, 100), 4096); listener.Listen(new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), 5000), 1024); e = new ManualResetEvent(false); var task = Task.Run((Action)clientDisconnect); Log(); Console.ReadLine(); running = false; task.Wait(); clientPool.Dispose(); listener.Dispose(); }