source: ntrip/trunk/GnssCenter/thrift/test1/server.cpp@ 8198

Last change on this file since 8198 was 4939, checked in by mervart, 12 years ago
File size: 1.2 KB
Line 
1#include <iostream>
2
3#include <thrift/protocol/TBinaryProtocol.h>
4#include <thrift/server/TSimpleServer.h>
5#include <thrift/transport/TServerSocket.h>
6#include <thrift/transport/TBufferTransports.h>
7
8#include "gen-cpp/myService.h"
9
10using namespace std;
11using namespace boost;
12using namespace ::apache::thrift;
13using namespace ::apache::thrift::protocol;
14using namespace ::apache::thrift::transport;
15using namespace ::apache::thrift::server;
16
17class myServiceHandler : virtual public myServiceIf {
18 public:
19 myServiceHandler() {}
20 void answer(std::string& answ, const std::string& question) {
21 cout << "Client asks: " << question << endl;
22 answ = "I am well, thanks.";
23 }
24};
25
26int main(int argc, char **argv) {
27 int port = 9090;
28 shared_ptr<myServiceHandler> handler(new myServiceHandler());
29 shared_ptr<TProcessor> processor(new myServiceProcessor(handler));
30 shared_ptr<TServerSocket> serverTransport(new TServerSocket(port));
31 shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
32 shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
33
34 TSimpleServer server(processor, serverTransport,
35 transportFactory, protocolFactory);
36 server.serve();
37 return 0;
38}
39
Note: See TracBrowser for help on using the repository browser.