本文整理汇总了C++中TCPClient::disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPClient::disconnect方法的具体用法?C++ TCPClient::disconnect怎么用?C++ TCPClient::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPClient
的用法示例。
在下文中一共展示了TCPClient::disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
#ifdef HAVE_TERMIOS_H
// Store terminal attributes.
SaveTerminalAttributes termAttrs;
#endif
// Sets the environment's default locale.
setlocale(LC_ALL, "");
// Register signal handler.
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = signal_handler;
if (sigaction(SIGINT, &sa, nullptr)) {
cout << "Could not register signal handler" << endl;
exit(1);
}
// Parse configuration.
Configuration configuration;
GetoptConfigParser parser( argc, argv );
if( !parser.parse( configuration ) ) {
exit(1);
}
// Register read line implementation.
ReadLine &rlConsumer = ReadLine::getInstance();
// Connect to a debugger instance.
TCPClient *client;
int error = TCPClient::Connect( configuration.getHost(),
configuration.getPort(), &client );
if( error ) {
cout << strerror( errno ) << endl;
exit(1);
}
// Initialize JS engine.
DebuggerCtxImpl dbgCtx(rlConsumer, *client);
JSDebugger dbg(dbgCtx);
error = dbg.init();
if( error ) {
dbg.destroy();
cout << "Cannot initialize JS engine: " << error << endl;
exit(1);
}
// Information for the client.
cout << "JavaScript Remote Debugger Client connected to a remote "\
"debugger.\nWaiting for a list of JavaScript contexts being " \
"debugged.\nType \"help context\" for more information." << endl;
ApplicationCtxImpl ctx;
MainEventHandler mainEventHandler( ctx );
client->setEventHandler( &mainEventHandler );
// Prepare FS Events loop.
std::vector<IFSEventProducer*> producers;
producers.push_back( client );
std::vector<IFSEventConsumer*> consumers;
consumers.push_back(client);
rlConsumer.registerReadline( &mainEventHandler );
consumers.push_back( &rlConsumer );
// The main debugger's loop.
FSEventLoop eventsLoop(producers, consumers);
// Initialize the main context.
ctx.setMainLoop( &eventsLoop );
ctx.setReadLineEditor( &rlConsumer );
ctx.setDebuggerEngine( &dbg );
error = eventsLoop.loop();
if( error ) {
cout << "Debugger interrupted with error: " << error << endl;
}
client->setEventHandler(nullptr);
client->disconnect(JDB_ERROR_NO_ERROR);
delete client;
dbg.destroy();
exit(0);
}