tcp_client_posix.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
  19. #define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
  20. #include <grpc/support/port_platform.h>
  21. #include "src/core/lib/iomgr/endpoint.h"
  22. #include "src/core/lib/iomgr/ev_posix.h"
  23. #include "src/core/lib/iomgr/tcp_client.h"
  24. /* Create an endpoint from a connected grpc_fd.
  25. fd: a connected FD. Ownership is taken.
  26. channel_args: may contain custom settings for the endpoint
  27. addr_str: destination address in printable format
  28. Returns: a new endpoint
  29. */
  30. grpc_endpoint* grpc_tcp_client_create_from_fd(
  31. grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
  32. /* Return a configured, unbound, unconnected TCP client grpc_fd.
  33. channel_args: may contain custom settings for the fd
  34. addr: the destination address
  35. mapped_addr: out parameter. addr mapped to an address appropriate to the
  36. type of socket FD created. For example, if addr is IPv4 and dual stack
  37. sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
  38. fdobj: out parameter. The new FD
  39. Returns: error, if any. Out parameters are not set on error
  40. */
  41. grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
  42. const grpc_resolved_address* addr,
  43. grpc_resolved_address* mapped_addr,
  44. grpc_fd** fdobj);
  45. /* Connect a configured TCP client grpc_fd.
  46. interested_parties: a set of pollsets that would be interested in this
  47. connection being established (in order to continue their work
  48. closure: called when complete. On success, *ep will be set.
  49. fdobj: an FD returned from grpc_tcp_client_prepare_fd(). Ownership is taken
  50. channel_args: may contain custom settings for the endpoint
  51. deadline: connection deadline
  52. ep: out parameter. Set before closure is called if successful
  53. */
  54. void grpc_tcp_client_create_from_prepared_fd(
  55. grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj,
  56. const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
  57. grpc_millis deadline, grpc_endpoint** ep);
  58. #endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */