From d6319001f38c5644835efdc24a4d283a768577b3 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 6 Mar 2015 23:51:23 -0800 Subject: [PATCH 1/4] Update helloworld --- cpp/helloworld/Makefile | 2 +- cpp/helloworld/greeter_client.cc | 4 +++- cpp/helloworld/greeter_server.cc | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/helloworld/Makefile b/cpp/helloworld/Makefile index 83f2ad49044..e6ddb644fa8 100644 --- a/cpp/helloworld/Makefile +++ b/cpp/helloworld/Makefile @@ -32,7 +32,7 @@ CXX = g++ CPPFLAGS = -I/usr/local/include -pthread CXXFLAGS = -std=c++11 -LDFLAGS = -L/usr/local/lib -lgrpc -lgrpc++ -lprotobuf -lpthread -ldl +LDFLAGS = -L/usr/local/lib -lgrpc -lgrpc++_unsecure -lprotobuf -lpthread -ldl PROTOC = protoc GRPC_CPP_PLUGIN = grpc_cpp_plugin GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)` diff --git a/cpp/helloworld/greeter_client.cc b/cpp/helloworld/greeter_client.cc index 0eb4746c65b..0cec4a36a14 100644 --- a/cpp/helloworld/greeter_client.cc +++ b/cpp/helloworld/greeter_client.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "helloworld.pb.h" @@ -80,7 +81,8 @@ int main(int argc, char** argv) { grpc_init(); GreeterClient greeter( - grpc::CreateChannelDeprecated("localhost:50051", ChannelArguments())); + grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(), + ChannelArguments())); std::string user("world"); std::string reply = greeter.SayHello(user); std::cout << "Greeter received: " << reply << std::endl; diff --git a/cpp/helloworld/greeter_server.cc b/cpp/helloworld/greeter_server.cc index e3dd36b0ed9..7885a160a05 100644 --- a/cpp/helloworld/greeter_server.cc +++ b/cpp/helloworld/greeter_server.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "helloworld.pb.h" @@ -64,7 +65,7 @@ void RunServer() { GreeterServiceImpl service; ServerBuilder builder; - builder.AddPort(server_address); + builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.RegisterService(&service); std::unique_ptr server(builder.BuildAndStart()); std::cout << "Server listening on " << server_address << std::endl; From 3eab5d2e4a58c8e8eddb2f5ef9812550cd35ed42 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 6 Mar 2015 23:55:29 -0800 Subject: [PATCH 2/4] Update route_guide --- cpp/route_guide/Makefile | 2 +- cpp/route_guide/route_guide_client.cc | 4 +++- cpp/route_guide/route_guide_server.cc | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/route_guide/Makefile b/cpp/route_guide/Makefile index 131956296cb..0a26090a85c 100644 --- a/cpp/route_guide/Makefile +++ b/cpp/route_guide/Makefile @@ -32,7 +32,7 @@ CXX = g++ CPPFLAGS = -I/usr/local/include -pthread CXXFLAGS = -std=c++11 -LDFLAGS = -L/usr/local/lib -lgpr -lgrpc -lgrpc++ -lprotobuf -lpthread -ldl +LDFLAGS = -L/usr/local/lib -lgpr -lgrpc -lgrpc++_unsecure -lprotobuf -lpthread -ldl PROTOC = protoc GRPC_CPP_PLUGIN = grpc_cpp_plugin GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)` diff --git a/cpp/route_guide/route_guide_client.cc b/cpp/route_guide/route_guide_client.cc index 0257affca07..d2f7673411f 100644 --- a/cpp/route_guide/route_guide_client.cc +++ b/cpp/route_guide/route_guide_client.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include "helper.h" @@ -242,7 +243,8 @@ 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::CreateChannelDeprecated("localhost:50051", ChannelArguments()), + grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(), + ChannelArguments()), db); std::cout << "-------------- GetFeature --------------" << std::endl; diff --git a/cpp/route_guide/route_guide_server.cc b/cpp/route_guide/route_guide_server.cc index d0a2ecd5d47..c6dbce5712a 100644 --- a/cpp/route_guide/route_guide_server.cc +++ b/cpp/route_guide/route_guide_server.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "helper.h" @@ -186,7 +187,7 @@ void RunServer(const std::string& db_path) { RouteGuideImpl service(db_path); ServerBuilder builder; - builder.AddPort(server_address); + builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.RegisterService(&service); std::unique_ptr server(builder.BuildAndStart()); std::cout << "Server listening on " << server_address << std::endl; From 85df5b7c37510349f557b2ac44aef71006e622f4 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 6 Mar 2015 23:58:42 -0800 Subject: [PATCH 3/4] Update text --- cpp/cpptutorial.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/cpptutorial.md b/cpp/cpptutorial.md index 01eff071088..9cd76fab073 100644 --- a/cpp/cpptutorial.md +++ b/cpp/cpptutorial.md @@ -214,7 +214,7 @@ void RunServer(const std::string& db_path) { RouteGuideImpl service(db_path); ServerBuilder builder; - builder.AddPort(server_address); + builder.AddPort(server_address, grpc::InsecureServerCredentials()); builder.RegisterService(&service); std::unique_ptr server(builder.BuildAndStart()); std::cout << "Server listening on " << server_address << std::endl; @@ -239,10 +239,10 @@ In this section, we'll look at creating a C++ client for our `RouteGuide` servic 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`: +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: ```cpp -grpc::CreateChannelDeprecated("localhost:50051", ChannelArguments()); +grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials(), ChannelArguments()); ``` Now we can use the channel to create our stub using the `NewStub` method provided in the `RouteGuide` class we generated from our .proto. From 2365ad193b45ed10c2becaedef6a72b1bf185097 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Sun, 8 Mar 2015 22:30:12 -0700 Subject: [PATCH 4/4] address comment --- cpp/helloworld/Makefile | 2 +- cpp/route_guide/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/helloworld/Makefile b/cpp/helloworld/Makefile index e6ddb644fa8..0333cc2e199 100644 --- a/cpp/helloworld/Makefile +++ b/cpp/helloworld/Makefile @@ -32,7 +32,7 @@ CXX = g++ CPPFLAGS = -I/usr/local/include -pthread CXXFLAGS = -std=c++11 -LDFLAGS = -L/usr/local/lib -lgrpc -lgrpc++_unsecure -lprotobuf -lpthread -ldl +LDFLAGS = -L/usr/local/lib -lgrpc++_unsecure -lgrpc -lgpr -lprotobuf -lpthread -ldl PROTOC = protoc GRPC_CPP_PLUGIN = grpc_cpp_plugin GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)` diff --git a/cpp/route_guide/Makefile b/cpp/route_guide/Makefile index 0a26090a85c..69bb6dbb8f8 100644 --- a/cpp/route_guide/Makefile +++ b/cpp/route_guide/Makefile @@ -32,7 +32,7 @@ CXX = g++ CPPFLAGS = -I/usr/local/include -pthread CXXFLAGS = -std=c++11 -LDFLAGS = -L/usr/local/lib -lgpr -lgrpc -lgrpc++_unsecure -lprotobuf -lpthread -ldl +LDFLAGS = -L/usr/local/lib -lgrpc++_unsecure -lgrpc -lgpr -lprotobuf -lpthread -ldl PROTOC = protoc GRPC_CPP_PLUGIN = grpc_cpp_plugin GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`