Update helloworld
This commit is contained in:
parent
226019c212
commit
d6319001f3
|
|
@ -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)`
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <grpc++/channel_interface.h>
|
||||
#include <grpc++/client_context.h>
|
||||
#include <grpc++/create_channel.h>
|
||||
#include <grpc++/credentials.h>
|
||||
#include <grpc++/status.h>
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include <grpc++/server.h>
|
||||
#include <grpc++/server_builder.h>
|
||||
#include <grpc++/server_context.h>
|
||||
#include <grpc++/server_credentials.h>
|
||||
#include <grpc++/status.h>
|
||||
#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> server(builder.BuildAndStart());
|
||||
std::cout << "Server listening on " << server_address << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue