void handler(const boost::system::error_code& error, int signal_number) { if (!error) { cerr << "SIGNAL(" << signal_number << ") : Caught SIGINT(SIGTERM)." << endl; io.stop(); } else { cerr << "SIGNAL(" << signal_number << ") : Error." << endl; } }
///退出 void talk_to_svr::on_exit(const std::string &msg) { std::string answer; std::istringstream iss(msg); iss >> answer >> answer; if (answer.find("succeed") == 0) { stop(); service.stop(); _csignal = ok_exit; } }
void request_timeout () { retry_timer.cancel(); death_timer.cancel(); // just tear everything down at this point. if( socket.is_open() ) socket.close(); if( requestCount.dec() == 0 ) ioservice.stop(); }
int _tmain(int argc, _TCHAR* argv[]) { char host[20] = "127.1.1.1"; unsigned short port = 10080; if( argc > 1 ) { ::wcstombs( host, argv[1], sizeof(host) ); } if( argc > 2 ) { try { port = lexical_cast<unsigned short>( wstring(argv[2]) ); } catch( const bad_lexical_cast & ) { cout << "input port illegal. expected unsigned short value, but "; wcout << argv[2] << endl; } } try { io_service::work work(ios_); run_service( ios_ ); shared_ptr<fastnetwork::io_connector> connector( new udp::udp_connector( ios_ ) ); connector->set_handler( session_created ); // connector->connect( ip::udp::endpoint( ip::address_v4::from_string(host), port ) ); // while using ip::address_v4::from_string(host), async_receive_from won't work // I don't know why. connector->connect( ip::udp::endpoint( ip::address_v4::from_string("127.0.0.1"), port ) ); while ( true ) { if ( ! client ) { ::Sleep(1000); } else { read_send( client ); // break; } } } catch (std::exception& e) { std::cerr << e.what() << std::endl; } ios_.stop(); while( true ) { ::Sleep( 10000 ); } return 0; }
void stopBTTrackers() { g_IOService.stop(); g_Thread.join(); }
void stopModule(io_service & ios) { ios.stop(); }