#include #include #include #include #include "../test/cpp_utils/SimpleMessage.hpp" #include #include #include #include // nanosleep // #include int main(int argc, char* argv[] ) { if ( argc != 4 ) { std::cerr << "Usage: " << argv[0] << " " << std::endl; return 1; } Logger::createInstance(); Logger::init(std::cout); Logger::setLogLevel(Logger::FINEST); SslConnection::init(); bool finished = false; SimpleMessage msg(&finished); SslConnection conn(argv[1], argv[2], &msg); conn.initClientContext(); SocketClient socketClient(&conn); if ( !socketClient.connect() ) { LOG_STATIC( Logger::ERR, "Couldn't connect to server, exiting..." ); SslConnection::destroy(); Logger::destroy(); return 1; } // wait for thread creation sleep(1); // send message to server std::string msg1(argv[3]); if ( !socketClient.send( msg1.c_str(), msg1.length()) ) { LOG_STATIC( Logger::ERR, "Couldn't send message to server, exiting..." ); SslConnection::destroy(); Logger::destroy(); return 1; } // wait for the complate &handled reply struct timespec tm = {0,1000}; while ( !finished && socketClient.isPolling() ) nanosleep(&tm, &tm) ; // socketClient.disconnect(); SslConnection::destroy(); Logger::destroy(); return 0; }