examples/cpp/features/unix_abstract/server.cc
Go to the documentation of this file.
1 // Copyright 2021 the gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <iostream>
16 #include <memory>
17 #include <string>
18 
19 #include "examples/protos/helloworld.grpc.pb.h"
20 
22 #include <grpcpp/grpcpp.h>
24 
25 using grpc::Server;
28 using grpc::Status;
32 
33 // Logic and data behind the server's behavior.
34 class GreeterServiceImpl final : public Greeter::Service {
36  HelloReply* reply) override {
37  reply->set_message(request->name());
38  std::cout << "Echoing: " << request->name() << std::endl;
39  return Status::OK;
40  }
41 };
42 
43 void RunServer() {
44  std::string server_address("unix-abstract:grpc%00abstract");
50  builder.RegisterService(&service);
51  std::unique_ptr<Server> server(builder.BuildAndStart());
52  std::cout << "Server listening on " << server_address << " ... ";
53  server->Wait();
54 }
55 
56 int main(int argc, char** argv) {
57  RunServer();
58 
59  return 0;
60 }
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
grpc::EnableDefaultHealthCheckService
void EnableDefaultHealthCheckService(bool enable)
Definition: health_check_service.cc:30
proto_server_reflection_plugin.h
benchmark.request
request
Definition: benchmark.py:77
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
framework.rpc.grpc_channelz.Server
Server
Definition: grpc_channelz.py:42
health_check_service_interface.h
hellostreamingworld_pb2.HelloRequest
HelloRequest
Definition: hellostreamingworld_pb2.py:102
OK
@ OK
Definition: cronet_status.h:43
server_address
std::string server_address("0.0.0.0:10000")
server
std::unique_ptr< Server > server
Definition: channelz_service_test.cc:330
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
GreeterServiceImpl::SayHello
Status SayHello(ServerContext *context, const HelloRequest *request, HelloReply *reply) override
Definition: examples/cpp/features/unix_abstract/server.cc:35
grpc::ServerBuilder
A builder class for the creation and startup of grpc::Server instances.
Definition: grpcpp/server_builder.h:86
grpcpp.h
helloworld.Greeter
Definition: helloworld.py:32
GreeterServiceImpl
Definition: grpc-helloworld.cc:39
hellostreamingworld_pb2.HelloReply
HelloReply
Definition: hellostreamingworld_pb2.py:109
main
int main(int argc, char **argv)
Definition: examples/cpp/features/unix_abstract/server.cc:56
server
Definition: examples/python/async_streaming/server.py:1
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
grpc::InsecureServerCredentials
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
Definition: insecure_server_credentials.cc:52
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
RunServer
void RunServer()
Definition: examples/cpp/features/unix_abstract/server.cc:43
grpc::reflection::InitProtoReflectionServerBuilderPlugin
void InitProtoReflectionServerBuilderPlugin()
Definition: proto_server_reflection_plugin.cc:66


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:16