All Classes Namespaces Functions Variables Typedefs Enumerations Friends
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/worker.h>
14 
15 namespace ucxx {
16 
23 class Listener : public Component {
24  private:
25  ucp_listener_h _handle{nullptr};
26  std::string _ip{};
27  uint16_t _port{0};
28 
43  Listener(std::shared_ptr<Worker> worker,
44  uint16_t port,
45  ucp_listener_conn_callback_t callback,
46  void* callbackArgs);
47 
48  public:
49  Listener() = delete;
50  Listener(const Listener&) = delete;
51  Listener& operator=(Listener const&) = delete;
52  Listener(Listener&& o) = delete;
53  Listener& operator=(Listener&& o) = delete;
54 
55  ~Listener();
56 
95  [[nodiscard]] friend std::shared_ptr<Listener> createListener(
96  std::shared_ptr<Worker> worker,
97  uint16_t port,
98  ucp_listener_conn_callback_t callback,
99  void* callbackArgs);
100 
122  [[nodiscard]] std::shared_ptr<Endpoint> createEndpointFromConnRequest(
123  ucp_conn_request_h connRequest, bool endpointErrorHandling = true);
124 
140  [[nodiscard]] ucp_listener_h getHandle();
141 
149  [[nodiscard]] uint16_t getPort();
150 
158  [[nodiscard]] std::string getIp();
159 };
160 
161 } // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:17
Component encapsulating a UCP listener.
Definition: listener.h:23
friend std::shared_ptr< Listener > createListener(std::shared_ptr< Worker > worker, uint16_t port, ucp_listener_conn_callback_t callback, void *callbackArgs)
Constructor of shared_ptr<ucxx::Listener>.
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.
std::shared_ptr< Endpoint > createEndpointFromConnRequest(ucp_conn_request_h connRequest, bool endpointErrorHandling=true)
Constructor for shared_ptr<ucxx::Endpoint>.
Definition: address.h:15