source: ntrip/trunk/GnssCenter/thrift/test2/client.cpp@ 4944

Last change on this file since 4944 was 4944, checked in by mervart, 9 years ago
File size: 1.1 KB
Line 
1#include <iostream>
2
3#include <thrift/protocol/TBinaryProtocol.h>
4#include <thrift/transport/TSocket.h>
5#include <thrift/transport/TTransportUtils.h>
6
7#include "gen-cpp/myService.h"
8
9using namespace std;
10using namespace boost;
11using namespace apache::thrift;
12using namespace apache::thrift::protocol;
13using namespace apache::thrift::transport;
14
15class myService : virtual public myServiceIf {
16 public:
17 myService() {}
18 void answer(std::string& answ, const std::string& question) {
19 cout << "Server asks: " << question << endl;
20 answ = "I am well, thanks.";
21 }
22
23};
24
25int main(int argc, char** argv) {
26 int port = 9090;
27 shared_ptr<TSocket> socket(new TSocket("localhost", port));
28 shared_ptr<TTransport> transport(new TBufferedTransport(socket));
29 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
30
31 shared_ptr<myService> service(new myService());
32 shared_ptr<TProcessor> processor(new myServiceProcessor(service));
33
34 try {
35 transport->open();
36
37 while (processor->process(protocol, protocol, 0)) {}
38
39 transport->close();
40 } catch (TException& exc) {
41 cout << "Exception: " << exc.what() << endl;
42 }
43
44 return 0;
45}
Note: See TracBrowser for help on using the repository browser.