inline void AsioThreadPool::joinThreadPool()
{
    m_io_svc.run();
}
Ejemplo n.º 2
0
static void asioFunction()
{
	boost::asio::io_service::work work(ioService);
	ioService.run();
}
Ejemplo n.º 3
0
 void start( void ){
     _accept();
     m_ioService.run();
 }
Ejemplo n.º 4
0
bool TCPClient::Start(boost::asio::io_service& IOService){
	IOService.run();
	return true;
}
Ejemplo n.º 5
0
int main(int argc, char** argv)
{
	std::string configFile = _TOURNAMENT_REALM_CONFIG;
    auto vm = GetConsoleArguments(argc, argv, configFile);
    // exit if help is enabled
    if (vm.count("help"))
        return 0;

    std::string configError;
    if (!sConfigMgr->LoadInitial(configFile, configError))
    {
        printf("Error in config file: %s\n", configError.c_str());
        return 1;
    }

    TC_LOG_INFO("server.authserver", "%s (authserver)", _FULLVERSION);
    TC_LOG_INFO("server.authserver", "<Ctrl-C> to stop.\n");
    TC_LOG_INFO("server.authserver", "Using configuration file %s.", configFile.c_str());
    TC_LOG_INFO("server.authserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
    TC_LOG_INFO("server.authserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);

    // authserver PID file creation
    std::string pidFile = sConfigMgr->GetStringDefault("PidFile", "");
    if (!pidFile.empty())
    {
        if (uint32 pid = CreatePIDFile(pidFile))
            TC_LOG_INFO("server.authserver", "Daemon PID: %u\n", pid);
        else
        {
            TC_LOG_ERROR("server.authserver", "Cannot create PID file %s.\n", pidFile.c_str());
            return 1;
        }
    }

    // Initialize the database connection
    if (!StartDB())
        return 1;

    // Get the list of realms for the server
    sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));

    if (sRealmList->size() == 0)
    {
        TC_LOG_ERROR("server.authserver", "No valid realms specified.");
        StopDB();
        return 1;
    }

    // Start the listening port (acceptor) for auth connections
    int32 port = sConfigMgr->GetIntDefault("RealmServerPort", 3724);
    if (port < 0 || port > 0xFFFF)
    {
        TC_LOG_ERROR("server.authserver", "Specified port out of allowed range (1-65535)");
        StopDB();
        return 1;
    }

    std::string bindIp = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");

    sAuthSocketMgr.StartNetwork(_ioService, bindIp, port);

    // Set signal handlers
    boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
#if PLATFORM == PLATFORM_WINDOWS
    signals.add(SIGBREAK);
#endif
    signals.async_wait(SignalHandler);

    // Set process priority according to configuration settings
    SetProcessPriority("server.authserver");

    // Enabled a timed callback for handling the database keep alive ping
    _dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
    _dbPingTimer.expires_from_now(boost::posix_time::minutes(_dbPingInterval));
    _dbPingTimer.async_wait(KeepDatabaseAliveHandler);

    // Start the io service worker loop
    _ioService.run();

    // Close the Database Pool and library
    StopDB();

    TC_LOG_INFO("server.authserver", "Halting process...");
    return 0;
}
Ejemplo n.º 6
0
 void run() {
     while (should_run) {
         ios.run();
         ios.reset();
     }
 }
	void thread_proc()
	{
		worker_service_.run();
	}
Ejemplo n.º 8
0
Archivo: main.cpp Proyecto: CCJY/coliru
void test()
{
	timer_.expires_from_now(milliseconds(0));
	timer_.async_wait(boost::bind(case1, boost::asio::placeholders::error));
	io_service_.run();
}
Ejemplo n.º 9
0
	void run()
	{
		accept();
		io.run();
	}
Ejemplo n.º 10
0
void WorkerThread(){
    Debug("Thread Start");
    io_service.run();
    Debug("Thread Finish");
}
Ejemplo n.º 11
0
	void operator()() const
	{
		service->run();
	}
void async_udp::tests_::detail::service_thread( boost::asio::io_service& service )
{
	service.run();
}
Ejemplo n.º 13
0
static void service_run(boost::asio::io_service& service)
{
    service.run();
}
 void IoServicesImpl::WorkerThread(boost::asio::io_service& ioService) {
     // std::cout << "hello worker" << std::endl;
     ioService.run();
     // std::cout << "Goodbye worker" << std::endl;
 }
Ejemplo n.º 15
0
 void run(){
     cuv::initCUDA(id);
     cuv::initialize_mersenne_twister_seeds();
     this->reg(ios,1);
     ios.run();
 }
Ejemplo n.º 16
0
int main() 
{ 
  boost::asio::ip::tcp::resolver::query query("www.highscore.de", "80"); 
  resolver.async_resolve(query, resolve_handler); 
  io_service.run(); 
} 
Ejemplo n.º 17
0
 void run ()
 {
     m_io_service.run ();
 }
Ejemplo n.º 18
0
void Connection::Run()
{
	netservice.run();
	netservice.reset();
}
void multicast_communication::data_receiver::start(boost::asio::io_service & service){
	service.run();
}
 void run() {
     timer_.expires_from_now(chrono::milliseconds(50));
     timer_.async_wait(bind(&printer::print, this));
     io_.run();
 }
Ejemplo n.º 21
0
	/** Run asio's event loop
	 *
	 * Handle asynchronous events blocking until all asynchronous
	 * operations have finished
	 */
	void run() { io_service_.run(); }
Ejemplo n.º 22
0
int main()
{
        // asynchron von STDIN lesen
        in.async_read_some(boost::asio::buffer(bytes), read_handler);
        ioservice.run();
}
 void work()
 {
   iris::glog<iris::Info>("Running component_manager");
   keep_alive_.reset(new boost::asio::io_service::work(io_service_));
   io_service_.run();
 }
Ejemplo n.º 24
0
void Timing()
{
	timer.async_wait(StopRun);
	io.run();
}
Ejemplo n.º 25
0
	void Run() {
		mpSrv->run();
	}
void service_thread( boost::asio::io_service& service )
{	
	service.run();
}
Ejemplo n.º 27
0
int main(int argc, char* argv[]) {
	START_EASYLOGGINGPP(argc, argv);
	el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime %level %loc : %msg");

	struct sigaction sigIntHandler;

	sigIntHandler.sa_handler = my_handler;
	sigemptyset(&sigIntHandler.sa_mask);
	sigIntHandler.sa_flags = 0;

	sigaction(SIGINT, &sigIntHandler, NULL);

	LOG(INFO) << "IBC-based End-to-End Authentication Gateway for the Internet of Things";

	po::options_description desc("Allowed options");
	desc.add_options()
		("help", "show help message")
		("interface", po::value<std::string>(), "network interface to bind to")
		("prefix", po::value<std::string>(), "IPv6 network prefix (48 bit) to use")
		("piggyback", po::value<bool>(), "Enable TA piggyback cache");

	po::variables_map vm;
	po::store(po::parse_command_line(argc, argv, desc), vm);
	po::notify(vm);

	if (vm.count("help")) {
		std::cout << desc << "\n";
		return 0;
	}

	std::string interface;
	if (vm.count("interface")) {
		interface = vm["interface"].as<std::string>();
	}
	if (interface.empty()) {
		LOG(ERROR) << "An interface has to be specified (--interface)";
		return 1;
	}

	bool piggybackEnabled = false;
	if (vm.count("piggyback")) {
		piggybackEnabled = vm["piggyback"].as<bool>();
	}


	std::string prefixString;
	if (vm.count("prefix")) {
		prefixString = vm["prefix"].as<std::string>();
	}

	LOG(INFO) << "Initialize RELIC...";
	core_init();

	LOG(INFO) << "Set elliptic curve...";
	ec_param_set_any();

	LOG(INFO) << "RELIC configuration:";
	conf_print();

	shared_ptr<TA> ta;
	if( access("ta.private.cbor", F_OK ) != -1 ) {
		LOG(INFO) << "Reading existing TA config from ta.private.cbor...";
		ta = TA::load(vectorFromFile("ta.private.cbor"));
	}
	else {
		LOG(INFO) << "No existing TA config found. Generating new TA...";
		ta = TA::init();

		LOG(INFO) << "Save TA config to ta.private.cbor...";
		std::vector<uint8_t> taAsCbor = ta->save();

		ofstream outfile("ta.private.cbor", ios::out | ios::binary); 
		outfile.write((char*)taAsCbor.data(), taAsCbor.size());
	}

	try {
		std::shared_ptr<NetworkInterface> ni = std::make_shared<NetworkInterface>(boost::asio::ip::address::from_string("fd2d:0388:6a7b::").to_v6());
		ni->configureInterface(interface, ta);
		
		// start dynamic configuration server (part of this authentication support server)
		std::shared_ptr<DynamicConfigurationServer> dcs = std::make_shared<DynamicConfigurationServer>(io_service, ni, ta);
		
		// start TA lookup responder (part of this authentication support server)
		std::shared_ptr<TALookupResponder> talr = std::make_shared<TALookupResponder>(io_service, ni, ta);

		// start TA piggyback service
		std::shared_ptr<TAPiggyBack> tapb;
		if (piggybackEnabled) {
			//tapb = std::make_shared<TAPiggyBack>(io_service, ni->getUsedAddress());
			tapb = std::make_shared<TAPiggyBack>(talr, ni->getUsedAddress());
		}


		io_service.run();
	}
	catch (std::exception& e) {
		LOG(INFO) << e.what();
		el::base::debug::StackTrace();
	}


	LOG(INFO) << "Clean up RELIC...";
	core_clean();
	return 0;
}
Ejemplo n.º 28
0
Archivo: main.cpp Proyecto: CCJY/coliru
 Demo() :
     m_IOService(),
     m_work(new boost::asio::io_service::work(m_IOService)),
     m_io_thread([this] { m_IOService.run(); })
 {
 }
Ejemplo n.º 29
0
 void start(){
     _ios.run();
 }
Ejemplo n.º 30
0
void work(boost::asio::io_service &io_){
    std::cout << "Worker thread calling io_.run()\n";
    io_.run();
}