Roger Meier | 122803b | 2012-06-18 20:23:58 +0000 | [diff] [blame] | 1 | Thrift transport sample project |
| 2 | ------------------------------- |
| 3 | |
| 4 | This cross-platform project has been built with Windows Visual Studio 10 and |
| 5 | OSX 10.7.1's g++. The client and server support socket and pipe transports |
| 6 | through command-line switches. |
| 7 | |
| 8 | Windows supports both named & anonymous pipes; *NIX gets only named |
| 9 | 'pipes' at this time. |
| 10 | |
| 11 | Windows-only at this time: |
| 12 | The client & server are double-ended. Both sides run a server and client to |
| 13 | enable full duplex bidirectional event signaling. They are simple command |
| 14 | line apps. The server runs until it's aborted (Ctl-C). The client connects to |
| 15 | the server, informs the server of its listening pipe/port, runs some more RPCs |
| 16 | and exits. The server also makes RPC calls to the client to demonstrate |
| 17 | bidirectional operation. |
| 18 | |
| 19 | Prequisites: |
| 20 | Boost -- tested with Boost 1.47, other versions may work. |
| 21 | libthrift library -- build the library under "thrift/lib/cpp/" |
| 22 | thrift IDL compiler -- download from http://thrift.apache.org/download/ |
| 23 | or build from "thrift/compiler/cpp". The IDL compiler version should |
| 24 | match the thrift source distribution's version. For instance, thrift-0.9.0 |
| 25 | has a different directory structure than thrift-0.8.0 and the generated |
| 26 | files are not compatible. |
| 27 | |
| 28 | Note: Bulding the thrift IDL compiler and library are beyond the scope |
| 29 | of this article. Please refer to the Thrift documentation in the respective |
| 30 | directories and online. |
| 31 | |
| 32 | |
| 33 | Microsoft Windows with Visual Studio 10 |
| 34 | ---------------------------------------- |
| 35 | Copy the IDL compiler 'thrift.exe' to this project folder or to a location in the path. |
| 36 | Run thriftme.bat to generate the interface source from the thrift files. |
| 37 | |
| 38 | Open transport-sample.sln and... |
| 39 | Adapt the Boost paths for the client and server projects. Right-click on each project, select |
| 40 | Properties, then: |
| 41 | Configuration Properties -> C/C++ -> General -> Additional Include Directories |
| 42 | Configuration Properties -> Linker -> General -> Additional Include Directories |
| 43 | |
| 44 | The stock path assumes that Boost is located at the same level as the thrift repo root. |
| 45 | |
| 46 | Run the following in separate command prompts from the Release or Debug |
| 47 | build folder: |
| 48 | server.exe -np test |
| 49 | client.exe -np test |
| 50 | |
| 51 | |
| 52 | *NIX flavors |
| 53 | ------------ |
| 54 | Build the thrift cpp library. |
| 55 | Build the IDL compiler and copy it to this project folder. |
| 56 | Run thriftme.sh to generate the interface source from the thrift files. |
| 57 | Run 'make' |
| 58 | |
| 59 | Run the following in separate shells: |
| 60 | server/server -np /tmp/test |
| 61 | client/client -np /tmp/test |