Listen() public method

public Listen ( IPEndPoint localEP, int backlog ) : void
localEP System.Net.IPEndPoint
backlog int
return void
Beispiel #1
0
        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();

            
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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");

            sendPool = new RioFixedBufferPool(10 * connections, 140 * pipeLineDeph);
            recivePool = new RioFixedBufferPool(10 * connections, 128 * pipeLineDeph);

            listener = new RioTcpListener(sendPool, recivePool, 1024);
            currentSegment = listener.PreAllocateWrite(GetResponse());
            responseBytes = GetResponse();
            //Task.Run(async () =>
            //{
            //    while (true)
            //    {
            //        UpdateResponse();
            //        await Task.Delay(60000);
            //    }
            //});

            listener.OnAccepted = new Action<RioConnectionOrientedSocket>(s => ThreadPool.QueueUserWorkItem(o => Servebuff((RioConnectionOrientedSocket)o), s));
            listener.Listen(new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), 5000), 1024 * connections);
            Console.ReadLine();
        }
Beispiel #4
0
 public static void ListenTcp()
 {
     RioTcpListener l = new RioTcpListener(new RioFixedBufferPool(16000, 65536), new RioFixedBufferPool(16000, 65536), (uint)Connections*2,16000,16000);
     l.OnAccepted = s =>
     {
         RioStream r = new RioStream(s);
         int totalRecived = 0;
         int currentRecived = 0;
         var pb = new byte[PullBytes];
         if (Pattern == "PushPull")
         {
             s.OnIncommingSegment = seg =>
             {
                 totalRecived += seg.CurrentContentLength;
                 currentRecived += seg.CurrentContentLength;
                 if (currentRecived >= PushBytes)
                 {
                     r.Write(pb, 0, pb.Length);
                     //s.WriteFixed(pb);
                     currentRecived = 0;
                 }
             };
         }
         else if (Pattern == "Pull")
             r.Write(new byte[Transfer], 0, Transfer);
         //s.WriteFixed(new byte[Transfer]);
         else if (Pattern == "Push")
         {
             s.OnIncommingSegment = seg =>
             {
                 totalRecived += seg.CurrentContentLength;
             };
             s.BeginReceive();
         }
         else if (Pattern == "Duplex")
         {
             s.WriteFixed(new byte[Transfer / 2]);
             s.OnIncommingSegment = seg =>
             {
                 totalRecived += seg.CurrentContentLength;
                 //if (apa >= Transfer / 2)
                 //    tcs.SetResult(null);
             };
         }
     };
     l.Listen(new IPEndPoint(new IPAddress(new byte[] { 0, 0, 0, 0 }), Port), 1024);
 }