#include #include #include #include #include #include #include "gen-cpp/myService.h" using namespace std; using namespace boost; using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; class myService : virtual public myServiceIf { public: myService() {} void answer(std::string& answ, const std::string& question) { // implemented on the client-side only } }; class myProcessorFactory : virtual public TProcessorFactory { public: myProcessorFactory() {}; shared_ptr getProcessor(const TConnectionInfo& info) { shared_ptr service(new myService()); shared_ptr processor(new myServiceProcessor(service)); cout << "connection " << endl; return processor; } }; int main(int argc, char **argv) { int port = 9090; shared_ptr serverTransport(new TServerSocket(port)); shared_ptr processorFactory(new myProcessorFactory()); shared_ptr transportFactory(new TBufferedTransportFactory()); shared_ptr protocolFactory(new TBinaryProtocolFactory()); TThreadedServer server(processorFactory, serverTransport, transportFactory, protocolFactory); server.serve(); return 0; }