You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
822 B
41 lines
822 B
#include <cpp_utils/Logger.hpp>
|
|
#include <cpp_utils/Common.hpp>
|
|
#include <cpp_utils/TcpConnection.hpp>
|
|
#include <cpp_utils/SocketServer.hpp>
|
|
|
|
#include "EchoMessage.hpp"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include <unistd.h> // sleep
|
|
|
|
|
|
int main(int argc, char* argv[] )
|
|
{
|
|
if ( argc != 3 ) {
|
|
std::cerr << "Usage: " << argv[0] << " <HOST> <PORT>" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
Logger::createInstance();
|
|
Logger::init(std::cout);
|
|
Logger::setLogLevel(Logger::FINEST);
|
|
|
|
EchoMessage msg;
|
|
TcpConnection conn(argv[1], argv[2], &msg);
|
|
SocketServer socketServer(&conn);
|
|
|
|
if ( !socketServer.start() ) {
|
|
LOG_STATIC( Logger::ERR, "Failed to start TCP server, exiting...");
|
|
Logger::destroy();
|
|
return 1;
|
|
}
|
|
|
|
// never reached
|
|
sleep(1);
|
|
|
|
socketServer.stop();
|
|
Logger::destroy();
|
|
return 0;
|
|
} |