1#include "timer.h" 2 3#include "InetAddress.h" 4#include "TlsAcceptor.h" 5#include "TlsConfig.h" 6#include "TlsStream.h" 7 8int main(int argc, char* argv[]) 9{ 10 TlsConfig config; 11 // config.setCaFile("ca.pem"); 12 config.setCertFile("server.pem"); 13 config.setKeyFile("server.pem"); 14 15 InetAddress listenAddr(4433); 16 TlsAcceptor acceptor(&config, listenAddr); 17 18 TlsStreamPtr stream = acceptor.accept(); 19 if (stream) 20 { 21 LOG_INFO << "OK"; 22 int64_t total = 0; 23 char buf[20 * 1024]; 24 int nr = 0; 25 Timer t; 26 t.start(); 27 while ( (nr = stream->receiveSome(buf, sizeof buf)) > 0) { 28 // LOG_INFO << "nr = " << nr; 29 total += nr; 30 } 31 // LOG_INFO << "nr = " << nr; 32 t.stop(); 33 LOG_INFO << "DONE " << total 34 << " " << (total / t.seconds() / 1e6) << " MB/s"; 35 } 36} 37 38