blob: 783935cd53d3206ded632c3fe0c8571a3c9d048a [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
David Garcia Quintas260a0022016-08-09 16:57:32 -07005To install gRPC on your system, follow the instructions to build from source
6[here](../../INSTALL.md). This also installs the protocol buffer compiler
7`protoc` (if you don't have it already), and the C++ gRPC plugin for `protoc`.
Abhishek Kumar3a5592c2015-02-20 15:32:42 -08008
LisaFCd1e11e72015-02-23 18:16:08 +00009## Hello C++ gRPC!
Tim Emiola10135582015-02-23 09:22:26 -080010
David Garcia Quintas260a0022016-08-09 16:57:32 -070011Here's how to build and run the C++ implementation of the [Hello
12World](../protos/helloworld.proto) example used in [Getting started](..).
Tim Emiola10135582015-02-23 09:22:26 -080013
LisaFCd1e11e72015-02-23 18:16:08 +000014### Client and server implementations
Tim Emiola10135582015-02-23 09:22:26 -080015
yang-gb00a3f62015-08-28 14:19:37 -070016The client implementation is at [greeter_client.cc](helloworld/greeter_client.cc).
Tim Emiola10135582015-02-23 09:22:26 -080017
yang-gb00a3f62015-08-28 14:19:37 -070018The server implementation is at [greeter_server.cc](helloworld/greeter_server.cc).
Tim Emiola10135582015-02-23 09:22:26 -080019
LisaFCd1e11e72015-02-23 18:16:08 +000020### Try it!
Yang Gao3054eba2015-02-24 14:36:18 -080021Build client and server:
David Garcia Quintas260a0022016-08-09 16:57:32 -070022
Yang Gao3054eba2015-02-24 14:36:18 -080023```sh
24$ make
25```
David Garcia Quintas260a0022016-08-09 16:57:32 -070026
Yang Gao84c263f2015-02-24 14:47:47 -080027Run the server, which will listen on port 50051:
David Garcia Quintas260a0022016-08-09 16:57:32 -070028
Yang Gao3054eba2015-02-24 14:36:18 -080029```sh
30$ ./greeter_server
31```
David Garcia Quintas260a0022016-08-09 16:57:32 -070032
Yang Gaoecee4242015-02-24 14:46:53 -080033Run the client (in a different terminal):
David Garcia Quintas260a0022016-08-09 16:57:32 -070034
Yang Gao3054eba2015-02-24 14:36:18 -080035```sh
36$ ./greeter_client
37```
David Garcia Quintas260a0022016-08-09 16:57:32 -070038
39If things go smoothly, you will see the "Greeter received: Hello world" in the
40client side output.
LisaFCd1e11e72015-02-23 18:16:08 +000041
42## Tutorial
43
yang-gb00a3f62015-08-28 14:19:37 -070044You can find a more detailed tutorial in [gRPC Basics: C++](cpptutorial.md)