#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; class myService : virtual public myServiceIf { public: myService() {} void answer(std::string& answ, const std::string& question) { cout << "Server asks: " << question << endl; answ = "I am well, thanks."; } }; int main(int argc, char** argv) { int port = 9090; shared_ptr socket(new TSocket("localhost", port)); shared_ptr transport(new TBufferedTransport(socket)); shared_ptr protocol(new TBinaryProtocol(transport)); shared_ptr service(new myService()); shared_ptr processor(new myServiceProcessor(service)); try { transport->open(); while (processor->process(protocol, protocol, 0)) {} transport->close(); } catch (TException& exc) { cout << "Exception: " << exc.what() << endl; } return 0; }