blob: e4b0eb698bffe5f536885bd85d0120cc3a2dd578 [file] [log] [blame] [view]
LisaFCd1e11e72015-02-23 18:16:08 +00001#gRPC in 3 minutes (C++)
Abhishek Kumar3a5592c2015-02-20 15:32:42 -08002
LisaFCd1e11e72015-02-23 18:16:08 +00003## Installation
4
Stanley Cheung6dd3c702016-03-03 13:53:49 -08005To install gRPC on your system, follow the instructions [here](../../INSTALL.md).
Abhishek Kumar3a5592c2015-02-20 15:32:42 -08006
LisaFCd1e11e72015-02-23 18:16:08 +00007## Hello C++ gRPC!
Tim Emiola10135582015-02-23 09:22:26 -08008
yang-gb00a3f62015-08-28 14:19:37 -07009Here's how to build and run the C++ implementation of the [Hello World](../protos/helloworld.proto) example used in [Getting started](..).
Tim Emiola10135582015-02-23 09:22:26 -080010
Stanley Cheung0a268212015-08-27 14:38:38 -070011The example code for this and our other examples lives in the `examples`
12directory. Clone this repository to your local machine by running the
Tim Emiola10135582015-02-23 09:22:26 -080013following command:
14
15
16```sh
Stanley Cheung0a268212015-08-27 14:38:38 -070017$ git clone https://github.com/grpc/grpc.git
Tim Emiola10135582015-02-23 09:22:26 -080018```
19
Stanley Cheung0a268212015-08-27 14:38:38 -070020Change your current directory to examples/cpp/helloworld
Tim Emiola10135582015-02-23 09:22:26 -080021
22```sh
Stanley Cheung0a268212015-08-27 14:38:38 -070023$ cd examples/cpp/helloworld/
Tim Emiola10135582015-02-23 09:22:26 -080024```
25
LisaFCd1e11e72015-02-23 18:16:08 +000026### Client and server implementations
Tim Emiola10135582015-02-23 09:22:26 -080027
yang-gb00a3f62015-08-28 14:19:37 -070028The client implementation is at [greeter_client.cc](helloworld/greeter_client.cc).
Tim Emiola10135582015-02-23 09:22:26 -080029
yang-gb00a3f62015-08-28 14:19:37 -070030The server implementation is at [greeter_server.cc](helloworld/greeter_server.cc).
Tim Emiola10135582015-02-23 09:22:26 -080031
LisaFCd1e11e72015-02-23 18:16:08 +000032### Try it!
Yang Gao3054eba2015-02-24 14:36:18 -080033Build client and server:
34```sh
35$ make
36```
Yang Gao84c263f2015-02-24 14:47:47 -080037Run the server, which will listen on port 50051:
Yang Gao3054eba2015-02-24 14:36:18 -080038```sh
39$ ./greeter_server
40```
Yang Gaoecee4242015-02-24 14:46:53 -080041Run the client (in a different terminal):
Yang Gao3054eba2015-02-24 14:36:18 -080042```sh
43$ ./greeter_client
44```
Yang Gaoecee4242015-02-24 14:46:53 -080045If things go smoothly, you will see the "Greeter received: Hello world" in the client side output.
LisaFCd1e11e72015-02-23 18:16:08 +000046
47## Tutorial
48
yang-gb00a3f62015-08-28 14:19:37 -070049You can find a more detailed tutorial in [gRPC Basics: C++](cpptutorial.md)