MCPcopy Create free account
hub / github.com/acl-dev/acl / run

Method run

lib_acl_cpp/samples/thread_client/thread_client.cpp:18–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void* thread_client::run()
19{
20 acl::socket_stream conn;
21
22 // ����Զ�̷�����
23 if (conn.open(server_addr_, 10, 10) == false)
24 {
25 printf("connect %s error %s\r\n", server_addr_.c_str(),
26 acl::last_serror());
27 return NULL;
28 }
29
30 char* data = (char*) acl_mymalloc(length_);
31 memset(data, 'X', length_);
32 data[length_ - 1] = '\n';
33
34 acl::string buf;
35
36 struct timeval begin;
37 gettimeofday(&begin, NULL);
38
39 int i = 0;
40 for (; i < count_; i++)
41 {
42 // �������дһ������
43 if (conn.write(data, length_) == -1)
44 {
45 printf("write to %s error %s\r\n",
46 server_addr_.c_str(), acl::last_serror());
47 break;
48 }
49
50 // �ӷ�������һ������
51 if (conn.gets(buf) == false)
52 {
53 printf("gets from %s error %s\r\n",
54 server_addr_.c_str(), acl::last_serror());
55 break;
56 }
57
58 if (i % 1000 == 0)
59 {
60 buf.format("total: %d, curr: %d", count_, i);
61 ACL_METER_TIME(buf.c_str());
62 }
63
64 if (keep_alive_)
65 continue;
66
67 // ������ö����ӣ����ȹر������ٴ�����
68 conn.close();
69 if (conn.open(server_addr_.c_str(), 10, 10) == false)
70 {
71 printf("connect %s error %s\r\n", server_addr_.c_str(),
72 acl::last_serror());
73 break;
74 }
75 }

Callers

nothing calls this directly

Calls 9

getsMethod · 0.80
last_serrorFunction · 0.50
gettimeofdayFunction · 0.50
stamp_subFunction · 0.50
openMethod · 0.45
c_strMethod · 0.45
writeMethod · 0.45
formatMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected