-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathProgram.cs
More file actions
102 lines (91 loc) · 3.82 KB
/
Program.cs
File metadata and controls
102 lines (91 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using test.window.client.Client;
namespace test.window.client
{
class Program
{
static void Main(string[] args)
{
Program program = new Program();
program.Test();
Console.Read();
}
private void Test()
{
int port = int.Parse(ConfigurationSettings.AppSettings["port"]);
string ip = ConfigurationSettings.AppSettings["ip"];
int receiveBufferSize = int.Parse(ConfigurationSettings.AppSettings["receiveBufferSize"]);
int sendnumber = int.Parse(ConfigurationSettings.AppSettings["sendnumber"]);
string senddata = ConfigurationSettings.AppSettings["senddata"];
byte[] data = Encoding.UTF8.GetBytes(senddata);
////单个实现测试
Push client = new Push(receiveBufferSize, ip, port);
//Pull client = new Pull(receiveBufferSize, ip, port);
//Pack client = new Pack(receiveBufferSize, ip, port, 0xff);
//for (int i = 0; i < sendnumber; i++)
//{
// client.Send(data, 0, data.Length);
//}
//Thread.Sleep(1000*10);
//client.Close();
//多线程测试
//ThreadPool.QueueUserWorkItem(new WaitCallback((object o) =>
//{
// Push client1 = new Push(receiveBufferSize, ip, port);
// //Pull client1 = new Pull(receiveBufferSize, ip, port);
// //Pack client1 = new Pack(receiveBufferSize, ip, port, 0xff);
// for (int i = 0; i < sendnumber; i++)
// {
// client1.Send(data, 0, data.Length);
// }
//}));
//ThreadPool.QueueUserWorkItem(new WaitCallback((object o) =>
//{
// Push client1 = new Push(receiveBufferSize, ip, 5556);
// //Pull client1 = new Pull(receiveBufferSize, ip, port);
// //Pack client1 = new Pack(receiveBufferSize, ip, port, 0xff);
// for (int i = 0; i < sendnumber; i++)
// {
// client1.Send(data, 0, data.Length);
// }
//}));
//ThreadPool.QueueUserWorkItem(new WaitCallback((object o) =>
//{
// Push client1 = new Push(receiveBufferSize, ip, 5557);
// //Pull client1 = new Pull(receiveBufferSize, ip, port);
// //Pack client1 = new Pack(receiveBufferSize, ip, port, 0xff);
// for (int i = 0; i < sendnumber; i++)
// {
// client1.Send(data, 0, data.Length);
// }
//}));
//ThreadPool.QueueUserWorkItem(new WaitCallback((object o) =>
//{
// Push client1 = new Push(receiveBufferSize, ip, 5558);
// //Pull client1 = new Pull(receiveBufferSize, ip, port);
// //Pack client1 = new Pack(receiveBufferSize, ip, port, 0xff);
// for (int i = 0; i < sendnumber; i++)
// {
// client1.Send(data, 0, data.Length);
// }
//}));
//多对象测试
//for (int j = 0; j < 200; j++)
//{
// Push client2 = new Push(receiveBufferSize, ip, port);
// //Pull client2 = new Pull(receiveBufferSize, ip, port);
// //Pack client2 = new Pack(receiveBufferSize, ip, port, 0xff);
// for (int i = 0; i < sendnumber; i++)
// {
// client2.Send(data, 0, data.Length);
// }
//}
}
}
}