Пример #1
0
 public RUdpServer(RUdpServerConfig config, ILoger loger)
 {
     Config = config;
     Loger = loger;
     SessionPool = new RUdpSessionPool();
     SessionPool.RUdpServer = this;
     receiveEventArgsList = new List<SocketAsyncEventArgs>(config.ListenerThreads);
     SocketArgsPool = new EventArgsPool(config.MaxSendEventArgs);
     BufferPool = new FixedBufferPool(config.MaxFixedBufferPoolSize, config.BufferSize);
 }
Пример #2
0
 static void Main(string[] args)
 {
     RUdpServerConfig configOne = new RUdpServerConfig { ServerId = 1, Name = "one", IP = "127.0.0.1", Port = 8089, BufferSize = 1024, MaxFixedBufferPoolSize = 1024 * 4, MaxConnections = 8000 };
     TestServer listener = new TestServer(configOne, loger);
     listener.Start();
     var session=listener.SessionPool.Pop();
     session.EndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8088);
     Console.WriteLine("服务器已启动");
     Console.ReadLine();
     int i = 0,max= 10000;
     Stopwatch sw = new Stopwatch();
     sw.Start();//开始记录时间
     while (i<=max)
     {
         session.SendAsync(Encoding.UTF8.GetBytes("测试数据服务器返回"+i));
         i++;
     }
     sw.Stop();
     Console.WriteLine("{0}次同步查询完成,运行时间:{1} 秒{2}毫秒", i, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds);
     Console.ReadLine();
 }
Пример #3
0
 public TestServer(RUdpServerConfig config, ILoger loger)
     : base(config, loger)
 {
 }
Пример #4
0
 static void Main(string[] args)
 {
     RUdpServerConfig configOne = new RUdpServerConfig { ServerId = 1, Name = "one", IP = "127.0.0.1", Port = 8088, BufferSize = 1024, MaxFixedBufferPoolSize = 1024 * 4, MaxConnections = 8000 };
     TestServer listener = new TestServer(configOne, loger);
     listener.Start();
     Console.WriteLine("服务器已启动");
     Console.ReadLine();
 }