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

Last change on this file since 8136 was 4951, checked in by mervart, 12 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(const std::string& question) {
19 cout << "Server asks: " << question << endl;
20 }
21
22};
23
24int main(int argc, char** argv) {
25 int port = 9090;
26 shared_ptr<TSocket> socket(new TSocket("localhost", port));
27 shared_ptr<TTransport> transport(new TBufferedTransport(socket));
28 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
29
30 shared_ptr<myService> service(new myService());
31 shared_ptr<TProcessor> processor(new myServiceProcessor(service));
32
33 try {
34 transport->open();
35
36 while (processor->process(protocol, protocol, 0)) {}
37
38 transport->close();
39 } catch (TException& exc) {
40 cout << "Exception: " << exc.what() << endl;
41 }
42
43 return 0;
44}
Note: See TracBrowser for help on using the repository browser.