listener.h
1 
5 #pragma once
6 
7 #include <memory>
8 #include <string>
9 
10 #include <ucp/api/ucp.h>
11 
12 #include <ucxx/component.h>
13 #include <ucxx/endpoint_builder.h>
14 #include <ucxx/listener_builder.h>
15 #include <ucxx/worker.h>
16 
17 namespace ucxx {
18 
19 class Listener;
26 class Listener : public Component {
27  private:
28  ucp_listener_h _handle{nullptr};
29  std::string _ip{};
30  uint16_t _port{0};
31 
53  Listener(std::shared_ptr<Worker> worker,
54  std::string host,
55  uint16_t port,
56  ucp_listener_conn_callback_t callback,
57  void* callbackArgs);
58 
59  public:
60  Listener() = delete;
61  Listener(const Listener&) = delete;
62  Listener& operator=(Listener const&) = delete;
63  Listener(Listener&& o) = delete;
64  Listener& operator=(Listener&& o) = delete;
65 
66  ~Listener();
67 
68  // Allow internal construction without exposing factory functions.
69  friend class detail::ConstructorFactory;
70 
80  [[nodiscard]] EndpointBuilder endpointBuilder(ucp_conn_request_h connRequest);
81 
97  [[nodiscard]] ucp_listener_h getHandle();
98 
106  [[nodiscard]] uint16_t getPort();
107 
115  [[nodiscard]] std::string getIp();
116 };
117 
118 } // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:21
Builder class for constructing std::shared_ptr<ucxx::Endpoint> objects.
Definition: endpoint_builder.h:28
Component encapsulating a UCP listener.
Definition: listener.h:26
EndpointBuilder endpointBuilder(ucp_conn_request_h connRequest)
Create a builder for an endpoint from a connection request.
std::string getIp()
Get the IP address to which the listener is bound to.
ucp_listener_h getHandle()
Get the underlying ucp_listener_h handle.
uint16_t getPort()
Get the port to which the listener is bound to.
Definition: address.h:16