public static void AnswerTest() { loger = new Loger(); var endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8088); QClient = new QueryClient(endPoint, loger); //client = new MyClient(endPoint, loger); //client.PacketProtocol = new TcpClientPacketProtocol(1024, 1024 * 4); QClient.PacketProtocol = new TcpClientPacketProtocol(1024, 1024 * 4); QClient.Connect(); // client.Connect(); Stopwatch sw = new Stopwatch(); Console.WriteLine("连接服务器成功"); int i = 0; string c = Console.ReadLine(); if (!string.IsNullOrEmpty(c)) allCount = int.Parse(c); sw.Start();//开始记录时间 while (i <= allCount) { i++; var data = Encoding.UTF8.GetBytes("测试数据kjfl发送大法师大法是大法师大法是否阿斯发达说" + i); var t = QClient.QueryAsync(data); // client.SendAsync(data); t.Wait(); //if (t.IsCompleted) // Console.WriteLine(Encoding.UTF8.GetString(t.Result)); //else // Console.WriteLine(i+":错误"); // Thread.Sleep(10); } sw.Stop(); Console.WriteLine("{0}次同步查询完成,运行时间:{1} 秒{2}毫秒", i, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds); Console.ReadLine(); }
public static void AnswerTest() { loger = new Loger(); var endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8088); QClient = new QueryClient(endPoint, loger); //client = new MyClient(endPoint, loger); //client.PacketProtocol = new TcpClientPacketProtocol(1024, 1024 * 4); QClient.PacketProtocol = new TcpClientPacketProtocol(1024, 1024 * 4); QClient.Connect(); // client.Connect(); Stopwatch sw = new Stopwatch(); Console.WriteLine("连接服务器成功"); int i = 0; string c = Console.ReadLine(); if (!string.IsNullOrEmpty(c)) { allCount = int.Parse(c); } sw.Start();//开始记录时间 while (i <= allCount) { i++; var data = Encoding.UTF8.GetBytes("测试数据kjfl发送大法师大法是大法师大法是否阿斯发达说" + i); var t = QClient.QueryAsync(data); // client.SendAsync(data); t.Wait(); //if (t.IsCompleted) // Console.WriteLine(Encoding.UTF8.GetString(t.Result)); //else // Console.WriteLine(i+":错误"); // Thread.Sleep(10); } sw.Stop(); Console.WriteLine("{0}次同步查询完成,运行时间:{1} 秒{2}毫秒", i, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds); Console.ReadLine(); }