aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--examples/cpp/README.md11
-rw-r--r--examples/cpp/cpptutorial.md18
-rw-r--r--examples/cpp/helloworld/README.md14
-rw-r--r--examples/cpp/helloworld/greeter_async_client.cc3
-rw-r--r--examples/cpp/helloworld/greeter_client.cc4
-rw-r--r--examples/cpp/route_guide/route_guide_client.cc4
6 files changed, 24 insertions, 30 deletions
diff --git a/examples/cpp/README.md b/examples/cpp/README.md
index 70418b4425..85c495099b 100644
--- a/examples/cpp/README.md
+++ b/examples/cpp/README.md
@@ -2,12 +2,11 @@
## 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).
+To install gRPC on your system, follow the instructions [here](../../INSTALL).
## Hello C++ gRPC!
-Here's how to build and run the C++ implementation of the [Hello World](examples/protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc/tree/master/examples).
+Here's how to build and run the C++ implementation of the [Hello World](../protos/helloworld.proto) 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
@@ -41,9 +40,9 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
### Client and server implementations
-The client implementation is at [greeter_client.cc](examples/cpp/helloworld/greeter_client.cc).
+The client implementation is at [greeter_client.cc](helloworld/greeter_client.cc).
-The server implementation is at [greeter_server.cc](examples/cpp/helloworld/greeter_server.cc).
+The server implementation is at [greeter_server.cc](helloworld/greeter_server.cc).
### Try it!
Build client and server:
@@ -62,4 +61,4 @@ If things go smoothly, you will see the "Greeter received: Hello world" in the c
## Tutorial
-You can find a more detailed tutorial in [gRPC Basics: C++](examples/cpp/cpptutorial.md)
+You can find a more detailed tutorial in [gRPC Basics: C++](cpptutorial.md)
diff --git a/examples/cpp/cpptutorial.md b/examples/cpp/cpptutorial.md
index 22be42d500..78de014f97 100644
--- a/examples/cpp/cpptutorial.md
+++ b/examples/cpp/cpptutorial.md
@@ -6,7 +6,7 @@ This tutorial provides a basic C++ programmer's introduction to working with gRP
- Generate server and client code using the protocol buffer compiler.
- Use the C++ gRPC API to write a simple client and server for your service.
-It assumes that you have read the [Getting started](https://github.com/grpc/grpc/tree/master/examples) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto3 version of the protocol buffers language, which is currently in alpha release: you can find out more in the [proto3 language guide](https://developers.google.com/protocol-buffers/docs/proto3) and see the [release notes](https://github.com/google/protobuf/releases) for the new version in the protocol buffers Github repository.
+It assumes that you have read the [Getting started](..) guide and are familiar with [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). Note that the example in this tutorial uses the proto3 version of the protocol buffers language, which is currently in alpha release: you can find out more in the [proto3 language guide](https://developers.google.com/protocol-buffers/docs/proto3) and see the [release notes](https://github.com/google/protobuf/releases) for the new version in the protocol buffers Github repository.
This isn't a comprehensive guide to using gRPC in C++: more reference documentation is coming soon.
@@ -18,7 +18,7 @@ With gRPC we can define our service once in a .proto file and implement clients
## Example code and setup
-The example code for our tutorial is in [examples/cpp/route_guide](examples/cpp/route_guide). To download the example, clone this repository by running the following command:
+The example code for our tutorial is in [examples/cpp/route_guide](route_guide). To download the example, clone this repository by running the following command:
```shell
$ git clone https://github.com/grpc/grpc.git
```
@@ -28,12 +28,12 @@ Then change your current directory to `examples/cpp/route_guide`:
$ cd examples/cpp/route_guide
```
-You also should have the relevant tools installed to generate the server and client interface code - if you don't already, follow the setup instructions in [the C++ quick start guide](examples/cpp).
+You also should have the relevant tools installed to generate the server and client interface code - if you don't already, follow the setup instructions in [gRPC in 3 minutes](README.md).
## Defining the service
-Our first step (as you'll know from [Getting started](examples/) is to define the gRPC *service* and the method *request* and *response* types using [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in [`examples/protos/route_guide.proto`](examples/protos/route_guide.proto).
+Our first step (as you'll know from [Getting started](..) is to define the gRPC *service* and the method *request* and *response* types using [protocol buffers] (https://developers.google.com/protocol-buffers/docs/overview). You can see the complete .proto file in [`examples/protos/route_guide.proto`](../protos/route_guide.proto).
To define a service, you specify a named `service` in your .proto file:
@@ -91,7 +91,7 @@ message Point {
Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler `protoc` with a special gRPC C++ plugin.
-For simplicity, we've provided a [makefile](examples/cpp/route_guide/Makefile) that runs `protoc` for you with the appropriate plugin, input, and output (if you want to run this yourself, make sure you've installed protoc and followed the gRPC code [installation instructions](https://github.com/grpc/grpc/blob/master/INSTALL) first):
+For simplicity, we've provided a [makefile](route_guide/Makefile) that runs `protoc` for you with the appropriate plugin, input, and output (if you want to run this yourself, make sure you've installed protoc and followed the gRPC code [installation instructions](../../INSTALL) first):
```shell
$ make route_guide.grpc.pb.cc route_guide.pb.cc
@@ -126,7 +126,7 @@ There are two parts to making our `RouteGuide` service do its job:
- Implementing the service interface generated from our service definition: doing the actual "work" of our service.
- Running a gRPC server to listen for requests from clients and return the service responses.
-You can find our example `RouteGuide` server in [examples/cpp/route_guide/route_guide_server.cc](examples/cpp/route_guide/route_guide_server.cc). Let's take a closer look at how it works.
+You can find our example `RouteGuide` server in [route_guide/route_guide_server.cc](route_guide/route_guide_server.cc). Let's take a closer look at how it works.
### Implementing RouteGuide
@@ -236,16 +236,16 @@ As you can see, we build and start our server using a `ServerBuilder`. To do thi
<a name="client"></a>
## Creating the client
-In this section, we'll look at creating a C++ client for our `RouteGuide` service. You can see our complete example client code in [examples/cpp/route_guide/route_guide_client.cc](examples/cpp/route_guide/route_guide_client.cc).
+In this section, we'll look at creating a C++ client for our `RouteGuide` service. You can see our complete example client code in [route_guide/route_guide_client.cc](route_guide/route_guide_client.cc).
### Creating a stub
To call service methods, we first need to create a *stub*.
-First we need to create a gRPC *channel* for our stub, specifying the server address and port we want to connect to and any special channel arguments - in our case we'll use the default `ChannelArguments` and no SSL:
+First we need to create a gRPC *channel* for our stub, specifying the server address and port we want to connect to without SSL:
```cpp
-grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(), ChannelArguments());
+grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials());
```
Now we can use the channel to create our stub using the `NewStub` method provided in the `RouteGuide` class we generated from our .proto.
diff --git a/examples/cpp/helloworld/README.md b/examples/cpp/helloworld/README.md
index 641aadd52d..b16c084583 100644
--- a/examples/cpp/helloworld/README.md
+++ b/examples/cpp/helloworld/README.md
@@ -2,7 +2,7 @@
### Install gRPC
Make sure you have installed gRPC on your system. Follow the instructions here:
-[https://github.com/grpc/grpc/blob/master/INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL).
+[https://github.com/grpc/grpc/blob/master/INSTALL](../../../INSTALL).
### Get the tutorial source code
@@ -34,7 +34,7 @@ types as protocol buffer message types. Both the client and the
server use interface code generated from the service definition.
Here's our example service definition, defined using protocol buffers IDL in
-[helloworld.proto](examples/protos/helloworld.proto). The `Greeting`
+[helloworld.proto](../../protos/helloworld.proto). The `Greeting`
service has one method, `hello`, that lets the server receive a single
`HelloRequest`
message from the remote client containing the user's name, then send back
@@ -94,7 +94,7 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
arguments as follows
```
- auto channel = CreateChannel("localhost:50051", InsecureCredentials(), ChannelArguments());
+ auto channel = CreateChannel("localhost:50051", InsecureCredentials());
```
- Create a stub. A stub implements the rpc methods of a service and in the
@@ -124,7 +124,7 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
}
```
-For a working example, refer to [greeter_client.cc](examples/cpp/helloworld/greeter_client.cc).
+For a working example, refer to [greeter_client.cc](greeter_client.cc).
### Writing a server
@@ -152,7 +152,7 @@ For a working example, refer to [greeter_client.cc](examples/cpp/helloworld/gree
std::unique_ptr<Server> server(builder.BuildAndStart());
```
-For a working example, refer to [greeter_server.cc](examples/cpp/helloworld/greeter_server.cc).
+For a working example, refer to [greeter_server.cc](greeter_server.cc).
### Writing asynchronous client and server
@@ -194,7 +194,7 @@ The channel and stub creation code is the same as the sync client.
}
```
-For a working example, refer to [greeter_async_client.cc](examples/cpp/helloworld/greeter_async_client.cc).
+For a working example, refer to [greeter_async_client.cc](greeter_async_client.cc).
#### Async server
@@ -253,7 +253,7 @@ maintain the state of each rpc and use the address of it as the unique tag. For
simplicity the server only uses one completion queue for all events, and runs a
main loop in `HandleRpcs` to query the queue.
-For a working example, refer to [greeter_async_server.cc](examples/cpp/helloworld/greeter_async_server.cc).
+For a working example, refer to [greeter_async_server.cc](greeter_async_server.cc).
diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc
index d99f89b135..875599e161 100644
--- a/examples/cpp/helloworld/greeter_async_client.cc
+++ b/examples/cpp/helloworld/greeter_async_client.cc
@@ -45,7 +45,6 @@
#include "helloworld.grpc.pb.h"
using grpc::Channel;
-using grpc::ChannelArguments;
using grpc::ClientAsyncResponseReader;
using grpc::ClientContext;
using grpc::CompletionQueue;
@@ -89,7 +88,7 @@ class GreeterClient {
int main(int argc, char** argv) {
GreeterClient greeter(grpc::CreateChannel(
- "localhost:50051", grpc::InsecureCredentials(), ChannelArguments()));
+ "localhost:50051", grpc::InsecureCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
diff --git a/examples/cpp/helloworld/greeter_client.cc b/examples/cpp/helloworld/greeter_client.cc
index dd0358ac95..3d2fcba610 100644
--- a/examples/cpp/helloworld/greeter_client.cc
+++ b/examples/cpp/helloworld/greeter_client.cc
@@ -43,7 +43,6 @@
#include "helloworld.grpc.pb.h"
using grpc::Channel;
-using grpc::ChannelArguments;
using grpc::ClientContext;
using grpc::Status;
using helloworld::HelloRequest;
@@ -75,8 +74,7 @@ class GreeterClient {
int main(int argc, char** argv) {
GreeterClient greeter(
- grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(),
- ChannelArguments()));
+ grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
diff --git a/examples/cpp/route_guide/route_guide_client.cc b/examples/cpp/route_guide/route_guide_client.cc
index 814def27f3..ec0a75e039 100644
--- a/examples/cpp/route_guide/route_guide_client.cc
+++ b/examples/cpp/route_guide/route_guide_client.cc
@@ -47,7 +47,6 @@
#include "route_guide.grpc.pb.h"
using grpc::Channel;
-using grpc::ChannelArguments;
using grpc::ClientContext;
using grpc::ClientReader;
using grpc::ClientReaderWriter;
@@ -235,8 +234,7 @@ int main(int argc, char** argv) {
// Expect only arg: --db_path=path/to/route_guide_db.json.
std::string db = examples::GetDbFileContent(argc, argv);
RouteGuideClient guide(
- grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(),
- ChannelArguments()),
+ grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()),
db);
std::cout << "-------------- GetFeature --------------" << std::endl;