Rev | Line | |
---|
[4939] | 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 |
|
---|
| 9 | using namespace std;
|
---|
| 10 | using namespace boost;
|
---|
| 11 | using namespace apache::thrift;
|
---|
| 12 | using namespace apache::thrift::protocol;
|
---|
| 13 | using namespace apache::thrift::transport;
|
---|
| 14 |
|
---|
| 15 | int main(int argc, char** argv) {
|
---|
| 16 | int port = 9090;
|
---|
| 17 | shared_ptr<TSocket> socket(new TSocket("localhost", port));
|
---|
| 18 | shared_ptr<TTransport> transport(new TBufferedTransport(socket));
|
---|
| 19 | shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
|
---|
| 20 | myServiceClient client(protocol);
|
---|
| 21 |
|
---|
| 22 | try {
|
---|
| 23 | transport->open();
|
---|
| 24 |
|
---|
| 25 | while (true) {
|
---|
| 26 | string answ;
|
---|
| 27 | client.answer(answ, "How are you?");
|
---|
| 28 | cout << "Server answers: " << answ << endl;
|
---|
| 29 | sleep(1);
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | transport->close();
|
---|
| 33 | } catch (TException& exc) {
|
---|
| 34 | cout << "Exception: " << exc.what() << endl;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | return 0;
|
---|
| 38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.