#gRPC in 3 minutes (C++)
To install gRPC on your system, follow the instructions here.
Here's how to build and run the C++ implementation of the Hello World example used in Getting started.
The example code for this and our other examples lives in the examples
directory. Clone this repository to your local machine by running the following command:
$ git clone https://github.com/grpc/grpc.git
Change your current directory to examples/cpp/helloworld
$ cd examples/cpp/helloworld/
To generate the client and server side interfaces:
$ make helloworld.grpc.pb.cc helloworld.pb.cc
Which internally invokes the proto-compiler as:
$ protoc -I ../../protos/ --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ../../protos/helloworld.proto $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
The client implementation is at greeter_client.cc.
The server implementation is at greeter_server.cc.
Build client and server:
$ make
Run the server, which will listen on port 50051:
$ ./greeter_server
Run the client (in a different terminal):
$ ./greeter_client
If things go smoothly, you will see the "Greeter received: Hello world" in the client side output.
You can find a more detailed tutorial in gRPC Basics: C++