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

Function main

lib_acl_cpp/samples/benchmark/connect/main.cpp:8–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6}
7
8int main(int argc, char* argv[])
9{
10 int ch, max = 100;
11 acl::string addr("127.0.0.1:8088");
12
13 while ((ch = getopt(argc, argv, "hs:n:")) > 0)
14 {
15 switch (ch)
16 {
17 case 'h':
18 usage(argv[0]);
19 return 0;
20 case 's':
21 addr = optarg;
22 break;
23 case 'n':
24 max = atoi(optarg);
25 break;
26 default:
27 usage(argv[0]);
28 return 0;
29 }
30 }
31
32
33 std::list<acl::socket_stream*> clients;
34
35 for (int i = 0; i < max; i++)
36 {
37 acl::socket_stream* client = new acl::socket_stream();
38 if (client->open(addr, 10, 10) == false)
39 {
40 printf("connect %s error %s\r\n",
41 addr.c_str(), acl::last_serror());
42 break;
43 }
44 else
45 printf("connect %s ok, fd: %d, max: %d, curr: %d\r\n",
46 addr.c_str(), client->sock_handle(), max, i);
47 clients.push_back(client);
48 }
49
50 printf("enter any key to exist\r\n");
51 getchar();
52
53 std::list<acl::socket_stream*>::iterator it = clients.begin();
54 for (; it != clients.end(); ++it)
55 delete (*it);
56
57 printf("Over now\r\n");
58 return 0;
59}

Callers

nothing calls this directly

Calls 9

beginMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
last_serrorFunction · 0.50
openMethod · 0.45
c_strMethod · 0.45
sock_handleMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…