diff --git a/cpp/cpptutorial.md b/cpp/cpptutorial.md index 01eff07..9cd76fa 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. diff --git a/cpp/helloworld/Makefile b/cpp/helloworld/Makefile index 5a7c34f..bfa9c08 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++_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/helloworld/greeter_client.cc b/cpp/helloworld/greeter_client.cc index 0eb4746..0cec4a3 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 e3dd36b..7885a16 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; diff --git a/cpp/route_guide/Makefile b/cpp/route_guide/Makefile index ea02944..ac0b034 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 -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/route_guide_client.cc b/cpp/route_guide/route_guide_client.cc index 0257aff..d2f7673 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 d0a2ecd..c6dbce5 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;