Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The "ThriftUsageC++" page has been changed by AkiraKitada.
http://wiki.apache.org/thrift/ThriftUsageC%2B%2B?action=diff&rev1=24&rev2=25

--------------------------------------------------

  {{{
  g++ -L/usr/local/lib -lthrift *.o -o Something_server
  }}}
- == Generating the client code ==
+ == Writing the client code ==
- A client is a bit simpler to generate.
+ {{{thrift}}} generates a client interface, but you have to hook it up a bit 
on your own.
  
  {{{
- #include "gen-cpp/DocRetrieval.h"  // As an example
+ #include "Something.h"  // As an example
  
  #include <transport/TSocket.h>
  #include <transport/TBufferTransports.h>
@@ -133, +133 @@

  using namespace apache::thrift::protocol;
  using namespace apache::thrift::transport;
  
+ using namespace Test;
  
  int main(int argc, char **argv) {
    boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
    boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
    boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
  
-   DocRetrievalClient client(protocol);
+   SomethingClient client(protocol);
    transport->open();
+   client.ping();
-   DocInstance doc;
-   if (argc == 2) {
-     uint32_t docid(atoi(argv[1]));
-     client.get(doc, docid);
-     // do something (important) with 'doc' now
-   }
    transport->close();
  
    return 0;
  }
  }}}
+ === Compiling ===
+ {{{
+ g++ -Wall -I/usr/local/include/thrift -c something_client.cpp -o client.o
+ }}}
+ === Linking ===
+ {{{
+ g++ -L/usr/local/lib -lthrift client.o Something.o constants.o types.o -o 
Something_client
+ }}}
  

Reply via email to