| 16 | static acl::polarssl_conf* __ssl_conf; |
| 17 | |
| 18 | static void test0(int i) |
| 19 | { |
| 20 | acl::socket_stream client; |
| 21 | acl::string addr("127.0.0.1:441"); |
| 22 | if (!client.open(addr.c_str(), 60, 60)) { |
| 23 | std::cout << "connect " << addr.c_str() |
| 24 | << " error!" << std::endl; |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | acl::polarssl_io* ssl = new acl::polarssl_io(*__ssl_conf, false); |
| 29 | if (client.setup_hook(ssl) == ssl) { |
| 30 | std::cout << "open ssl " << addr.c_str() |
| 31 | << " error!" << std::endl; |
| 32 | ssl->destroy(); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | char line[1024]; |
| 37 | memset(line, 'x', sizeof(line)); |
| 38 | line[1023] = 0; |
| 39 | line[1022] = '\n'; |
| 40 | if (client.write(line, strlen(line)) == -1) { |
| 41 | std::cout << "write to " << addr.c_str() |
| 42 | << " error!" << std::endl; |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | size_t n = sizeof(line); |
| 47 | if (!client.gets(line, &n)) { |
| 48 | std::cout << "gets from " << addr.c_str() |
| 49 | << " error!" << std::endl; |
| 50 | return; |
| 51 | } |
| 52 | if (i < 10) { |
| 53 | std::cout << ">>gets: " << line << std::endl; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | static void test1(const char* domain, int port, bool use_gzip, bool use_ssl) |
| 58 | { |