#include #include "gen-cpp/DemoService.h" #include #include #include using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace std; #define REMOTE_ADDRESS "192.168.109.1" #define REMOTE_PORT 9999 int main(int argc, char **argv) { string res; ::std::shared_ptr socket(new TSocket(REMOTE_ADDRESS, REMOTE_PORT)); ::std::shared_ptr transport(new TBufferedTransport(socket)); ::std::shared_ptr protocol(new TBinaryProtocol(transport)); DemoServiceClient client(protocol); transport->open(); client.ping(res, "From C++ Client"); cout << res << '\n'; client.post(res, "{\"Source\":\"C++\"}"); cout << res << '\n'; transport->close(); return 0; } // g++ -g -I/usr/local/include/thrift gen-cpp/DemoService.cpp client.cpp -lthrift -L/usr/local/lib/*.so -o client