Debian Codegraph @

src/core/lib/iomgr/tcp_client_posix.h

raw
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 #ifndef GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
20 #define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include "src/core/lib/iomgr/endpoint.h"
25 #include "src/core/lib/iomgr/ev_posix.h"
26 #include "src/core/lib/iomgr/socket_utils_posix.h"
27 #include "src/core/lib/iomgr/tcp_client.h"
28
29 /* Create an endpoint from a connected grpc_fd.
30
31 fd: a connected FD. Ownership is taken.
32 config: may contain custom settings for the endpoint
33 addr_str: destination address in printable format
34 slice_allocator: ownership is taken by client.
35 Returns: a new endpoint
36 */
37 grpc_endpoint* grpc_tcp_create_from_fd(
38 grpc_fd* fd, const grpc_event_engine::experimental::EndpointConfig& config,
39 absl::string_view addr_str);
40
41 /* Return a configured, unbound, unconnected TCP client fd.
42
43 options: may contain custom settings for the fd
44 addr: the destination address
45 mapped_addr: out parameter. addr mapped to an address appropriate to the
46 type of socket FD created. For example, if addr is IPv4 and dual stack
47 sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
48 fd: out parameter. The new FD
49 Returns: error, if any. Out parameters are not set on error
50 */
51 grpc_error_handle grpc_tcp_client_prepare_fd(
52 const grpc_core::PosixTcpOptions& options,
53 const grpc_resolved_address* addr, grpc_resolved_address* mapped_addr,
54 int* fd);
55
56 /* Connect a configured TCP client fd.
57
58 interested_parties: a set of pollsets that would be interested in this
59 connection being established (in order to continue their work
60 closure: called when complete. On success, *ep will be set.
61 fd: an FD returned from grpc_tcp_client_prepare_fd().
62 options: may contain custom settings for the endpoint
63 deadline: connection deadline
64 ep: out parameter. Set before closure is called if successful
65 */
66 int64_t grpc_tcp_client_create_from_prepared_fd(
67 grpc_pollset_set* interested_parties, grpc_closure* closure, const int fd,
68 const grpc_core::PosixTcpOptions& options,
69 const grpc_resolved_address* addr, grpc_core::Timestamp deadline,
70 grpc_endpoint** ep);
71
72 #endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */