Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 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 "src/core/lib/iomgr/endpoint.h" |
| 23 | #include "src/core/lib/iomgr/ev_posix.h" |
| 24 | #include "src/core/lib/iomgr/tcp_client.h" |
| 25 | |
Dan Born | bdf6391 | 2017-11-17 14:31:00 -0800 | [diff] [blame] | 26 | /* Create an endpoint from a connected grpc_fd. |
| 27 | |
| 28 | fd: a connected FD. Ownership is taken. |
| 29 | channel_args: may contain custom settings for the endpoint |
| 30 | addr_str: destination address in printable format |
| 31 | Returns: a new endpoint |
| 32 | */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 33 | grpc_endpoint* grpc_tcp_client_create_from_fd( |
Yash Tibrewal | 8cf1470 | 2017-12-06 09:47:54 -0800 | [diff] [blame] | 34 | grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str); |
Craig Tiller | 8695876 | 2016-09-23 12:05:34 -0700 | [diff] [blame] | 35 | |
Dan Born | bdf6391 | 2017-11-17 14:31:00 -0800 | [diff] [blame] | 36 | /* Return a configured, unbound, unconnected TCP client grpc_fd. |
| 37 | |
| 38 | channel_args: may contain custom settings for the fd |
| 39 | addr: the destination address |
| 40 | mapped_addr: out parameter. addr mapped to an address appropriate to the |
| 41 | type of socket FD created. For example, if addr is IPv4 and dual stack |
| 42 | sockets are available, mapped_addr will be an IPv4-mapped IPv6 address |
| 43 | fdobj: out parameter. The new FD |
| 44 | Returns: error, if any. Out parameters are not set on error |
| 45 | */ |
| 46 | grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args, |
| 47 | const grpc_resolved_address* addr, |
| 48 | grpc_resolved_address* mapped_addr, |
| 49 | grpc_fd** fdobj); |
| 50 | |
| 51 | /* Connect a configured TCP client grpc_fd. |
| 52 | |
| 53 | interested_parties: a set of pollsets that would be interested in this |
| 54 | connection being established (in order to continue their work |
| 55 | closure: called when complete. On success, *ep will be set. |
| 56 | fdobj: an FD returned from grpc_tcp_client_prepare_fd(). Ownership is taken |
| 57 | channel_args: may contain custom settings for the endpoint |
| 58 | deadline: connection deadline |
| 59 | ep: out parameter. Set before closure is called if successful |
| 60 | */ |
| 61 | void grpc_tcp_client_create_from_prepared_fd( |
| 62 | grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj, |
| 63 | const grpc_channel_args* channel_args, const grpc_resolved_address* addr, |
| 64 | grpc_millis deadline, grpc_endpoint** ep); |
| 65 | |
Yash Tibrewal | 12fc6d4 | 2017-10-09 16:43:34 -0700 | [diff] [blame] | 66 | #endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ |