client_crash_test_server.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include <iostream>
20 #include <memory>
21 #include <string>
22 
23 #include "absl/flags/flag.h"
24 
25 #include <grpc/support/log.h>
26 #include <grpcpp/server.h>
27 #include <grpcpp/server_builder.h>
28 #include <grpcpp/server_context.h>
29 
30 #include "src/proto/grpc/testing/echo.grpc.pb.h"
32 
33 ABSL_FLAG(std::string, address, "", "Address to bind to");
34 
35 using grpc::testing::EchoRequest;
36 using grpc::testing::EchoResponse;
37 
38 namespace grpc {
39 namespace testing {
40 
41 class ServiceImpl final : public grpc::testing::EchoTestService::Service {
43  ServerContext* /*context*/,
45  EchoRequest request;
46  EchoResponse response;
47  while (stream->Read(&request)) {
48  gpr_log(GPR_INFO, "recv msg %s", request.message().c_str());
49  response.set_message(request.message());
50  stream->Write(response);
51  }
52  return Status::OK;
53  }
54 };
55 
56 void RunServer() {
58 
60  builder.AddListeningPort(absl::GetFlag(FLAGS_address),
62  builder.RegisterService(&service);
63  std::unique_ptr<Server> server(builder.BuildAndStart());
64  std::cout << "Server listening on " << absl::GetFlag(FLAGS_address)
65  << std::endl;
66  server->Wait();
67 }
68 } // namespace testing
69 } // namespace grpc
70 
71 int main(int argc, char** argv) {
72  grpc::testing::InitTest(&argc, &argv, true);
74 
75  return 0;
76 }
grpc::testing::InitTest
void InitTest(int *argc, char ***argv, bool remove_flags)
Definition: test_config_cc.cc:28
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
testing
Definition: aws_request_signer_test.cc:25
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
log.h
grpc
Definition: grpcpp/alarm.h:33
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
grpc::ServerReaderWriter
Definition: grpcpp/impl/codegen/sync_stream.h:786
grpc::testing::RunServer
void RunServer()
Definition: client_crash_test_server.cc:56
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
grpc::ServerBuilder
A builder class for the creation and startup of grpc::Server instances.
Definition: grpcpp/server_builder.h:86
main
int main(int argc, char **argv)
Definition: client_crash_test_server.cc:71
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc::Status::OK
static const Status & OK
An OK pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:113
grpc.server
def server(thread_pool, handlers=None, interceptors=None, options=None, maximum_concurrent_rpcs=None, compression=None, xds=False)
Definition: src/python/grpcio/grpc/__init__.py:2034
absl::GetFlag
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
Definition: abseil-cpp/absl/flags/flag.h:98
ABSL_FLAG
ABSL_FLAG(std::string, address, "", "Address to bind to")
server
Definition: examples/python/async_streaming/server.py:1
grpc::testing::ServiceImpl::BidiStream
Status BidiStream(ServerContext *, ServerReaderWriter< EchoResponse, EchoRequest > *stream) override
Definition: client_crash_test_server.cc:42
grpc::testing::ServiceImpl
Definition: client_crash_test_server.cc:41
server_context.h
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
test_config.h
grpc::InsecureServerCredentials
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
Definition: insecure_server_credentials.cc:52
server.h
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
server_builder.h
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:55