endpoint_pair_posix.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
20 
22 
23 #ifdef GRPC_POSIX_SOCKET_TCP
24 
25 #include <errno.h>
26 #include <fcntl.h>
27 #include <string.h>
28 #include <sys/socket.h>
29 #include <sys/types.h>
30 
31 #include <string>
32 
33 #include "absl/strings/str_cat.h"
34 
35 #include <grpc/support/alloc.h>
36 #include <grpc/support/log.h>
37 
44 
45 static void create_sockets(int sv[2]) {
46  int flags;
48  flags = fcntl(sv[0], F_GETFL, 0);
49  GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0);
50  flags = fcntl(sv[1], F_GETFL, 0);
51  GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
54 }
55 
58  int sv[2];
60  create_sockets(sv);
62  std::string final_name = absl::StrCat(name, ":client");
66  .ToC();
67  p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name.c_str(), false),
68  new_args, "socketpair-server");
69  final_name = absl::StrCat(name, ":server");
70  p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name.c_str(), false),
71  new_args, "socketpair-client");
72  grpc_channel_args_destroy(new_args);
73  return p;
74 }
75 
76 #endif
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
log.h
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
string.h
grpc_set_socket_no_sigpipe_if_possible
grpc_error_handle grpc_set_socket_no_sigpipe_if_possible(int fd)
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
setup.name
name
Definition: setup.py:542
xds_manager.p
p
Definition: xds_manager.py:60
grpc_channel_args
Definition: grpc_types.h:132
endpoint_pair.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_create_socketpair_if_unix
void grpc_create_socketpair_if_unix(int sv[2])
Definition: unix_sockets_posix_noop.cc:29
grpc_core::CoreConfiguration::Get
static const CoreConfiguration & Get()
Definition: core_configuration.h:82
grpc_fd_create
grpc_fd * grpc_fd_create(int fd, const char *name, bool track_err)
tcp_posix.h
grpc_tcp_create
grpc_endpoint * grpc_tcp_create(grpc_fd *fd, const grpc_channel_args *args, absl::string_view peer_string)
grpc_core::ChannelArgs::ToC
const grpc_channel_args * ToC() const
Definition: channel_args.cc:94
grpc_channel_args_destroy
void grpc_channel_args_destroy(grpc_channel_args *a)
Definition: channel_args.cc:360
grpc_core::CoreConfiguration::channel_args_preconditioning
const ChannelArgsPreconditioning & channel_args_preconditioning() const
Definition: core_configuration.h:139
grpc_core::ExecCtx
Definition: exec_ctx.h:97
unix_sockets_posix.h
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
port.h
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
alloc.h
grpc_iomgr_create_endpoint_pair
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name, grpc_channel_args *args)
socket_utils_posix.h
flags
uint32_t flags
Definition: retry_filter.cc:632
grpc_endpoint_pair
Definition: endpoint_pair.h:26
grpc_core::ChannelArgsPreconditioning::PreconditionChannelArgs
ChannelArgs PreconditionChannelArgs(const grpc_channel_args *args) const
Definition: channel_args_preconditioning.cc:34
errno.h
api.h
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:19