diff options
author | Stanley Cheung <stanleycheung@google.com> | 2015-08-27 14:00:20 -0700 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2015-08-27 14:00:20 -0700 |
commit | 20fa6693f3836bf1418176ec78b26feaf51a369d (patch) | |
tree | 5975f66d7c6eb447baeea97fb62cdffa19d5c2e5 /examples/cpp/README.md | |
parent | b2bea23365acb0bcc1b5adba2d5b2fa5a22eb872 (diff) |
move examples to correct locations
Diffstat (limited to 'examples/cpp/README.md')
-rw-r--r-- | examples/cpp/README.md | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/examples/cpp/README.md b/examples/cpp/README.md new file mode 100644 index 0000000000..e0a09ff8b8 --- /dev/null +++ b/examples/cpp/README.md @@ -0,0 +1,65 @@ +#gRPC in 3 minutes (C++) + +## Installation + +To install gRPC on your system, follow the instructions here: +[https://github.com/grpc/grpc/blob/master/INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL). + +## Hello C++ gRPC! + +Here's how to build and run the C++ implementation of the [Hello World](https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc-common). + +The example code for this and our other examples lives in the `grpc-common` +GitHub repository. Clone this repository to your local machine by running the +following command: + + +```sh +$ git clone https://github.com/grpc/grpc-common.git +``` + +Change your current directory to grpc-common/cpp/helloworld + +```sh +$ cd grpc-common/cpp/helloworld/ +``` + + +### Generating gRPC code + +To generate the client and server side interfaces: + +```sh +$ make helloworld.grpc.pb.cc helloworld.pb.cc +``` +Which internally invokes the proto-compiler as: + +```sh +$ protoc -I ../../protos/ --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ../../protos/helloworld.proto +$ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto +``` + +### Client and server implementations + +The client implementation is at [greeter_client.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_client.cc). + +The server implementation is at [greeter_server.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_server.cc). + +### Try it! +Build client and server: +```sh +$ make +``` +Run the server, which will listen on port 50051: +```sh +$ ./greeter_server +``` +Run the client (in a different terminal): +```sh +$ ./greeter_client +``` +If things go smoothly, you will see the "Greeter received: Hello world" in the client side output. + +## Tutorial + +You can find a more detailed tutorial in [gRPC Basics: C++](https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md) |