Ok thx for that tip. -----Message d'origine----- De : Spencer Brown [mailto:[email protected]] Envoyé : lundi 17 août 2015 16:51 À : [email protected] Objet : Re: C++ TNonblockingserver graceful exit
Write a small C++ client that connects to your server on localhost and calls server.shutdown(). Run it in another terminal window. This is not exactly "pressing escape" but it will work. If you really need the "press escape" behavior in a single window, change your server launcher code to start the server in another process, then listen for console input and when you get the escape, run the above mentioned client and exit after a couple of seconds. > On Aug 17, 2015, at 8:50 AM, Alexandre Iglesias <[email protected]> wrote: > > Hello, thrift mailing list! > > When using a TNonBlockingServer in the following way (console application in > C++) in the main thread, can I implement something that would shut it down > when pressing escape ? > > > boost::shared_ptr<ThriftGoatServiceHandler> handler(new > ThriftGoatServiceHandler()); boost::shared_ptr<TProcessor> > processor(new GoatThriftServiceProcessor(handler)); > boost::shared_ptr<TProtocolFactory> protocolFactory(new > TBinaryProtocolFactory()); TNonblockingServer server(processor, > protocolFactory, port); try { > server.serve(); > } >
