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

Last change on this file since 5393 was 4951, checked in by mervart, 11 years ago
File size: 1.1 KB
RevLine 
[4942]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
[4944]15class myService : virtual public myServiceIf {
[4942]16 public:
[4944]17 myService() {}
[4951]18 void answer(const std::string& question) {
[4942]19 cout << "Server asks: " << question << endl;
20 }
21
22};
23
24int main(int argc, char** argv) {
25 int port = 9090;
[4944]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));
[4942]29
[4944]30 shared_ptr<myService> service(new myService());
31 shared_ptr<TProcessor> processor(new myServiceProcessor(service));
[4942]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.