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

Function test

lib_acl_cpp/samples/ssl/ssl_client2/ssl_client.cpp:11–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9static acl::sslbase_conf* __ssl_conf;
10
11static bool test(const char* addr, int k, int nloop)
12{
13 acl::socket_stream client;
14 if (!client.open(addr, 60, 60)) {
15 std::cout << "connect " << addr << " error!" << std::endl;
16 exit (1);
17 }
18
19 acl::sslbase_io* ssl = __ssl_conf->create(false);
20 if (client.setup_hook(ssl) == ssl) {
21 std::cout << "open ssl " << addr << " error!" << std::endl;
22 ssl->destroy();
23 exit (1);
24 }
25
26 std::cout << "ssl handshake ok, k: " << k << std::endl;
27
28 for (int i = 0 ; i < nloop; i++) {
29 char line[1024], line2[1024];
30 memset(line, 'x', sizeof(line));
31 line[1023] = 0;
32 line[1022] = '\n';
33 if (client.write(line, strlen(line)) == -1) {
34 std::cout << "write to " << addr << " error!" << std::endl;
35 return false;
36 }
37
38 size_t n = sizeof(line2);
39 if (!client.gets(line2, &n)) {
40 std::cout << "gets from " << addr << " error!"
41 << acl_last_serror() << std::endl;
42 return false;
43 }
44 if (memcmp(line, line2, n) != 0) {
45 std::cout << "read invalid line" << std::endl;
46 return false;
47 }
48 if (i < 1 && k < 10) {
49 std::cout << ">>gets(" << n << "): " << line2 << std::endl;
50 }
51 if (i > 0 && i % 1000 == 0) {
52 char buf[256];
53 snprintf(buf, sizeof(buf), "write count: %d", i);
54 ACL_METER_TIME(buf);
55 }
56 }
57
58 return true;
59}
60
61class test_thread : public acl::thread
62{

Callers 1

runMethod · 0.70

Calls 7

acl_last_serrorFunction · 0.85
getsMethod · 0.80
openMethod · 0.45
createMethod · 0.45
setup_hookMethod · 0.45
destroyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…