Address#
2026-03-31
3 min read time
The ucxx::Address class represents a worker address that can be used to establish
connections between endpoints. Addresses are obtained from workers and can be serialized
for out-of-band exchange.
#include <ucxx/address.h>
namespace ucxx
-
class Address : public ucxx::Component#
Component encapsulating the address of a UCP worker.
A UCP worker has a unique address that can is contained in a
ucp_address_t*object, this class encapsulates that object and provides methods to simplify its handling.Public Functions
- ucp_address_t *getHandle(
Get the underlying
ucp_address_t*handle.Lifetime of the
ucp_address_t*handle is managed by theucxx::Addressobject and its ownership is non-transferrable. Once theucxx::Addressis destroyed the handle is not valid anymore, it is the user’s responsibility to ensure the owner’s lifetime while using the handle.// address is `std::shared_ptr<ucxx::Address>` ucp_address_t* addressHandle = address->getHandle();
- Returns:
The underlying
ucp_address_thandle.
- size_t getLength(
Get the length of the
ucp_address_t*handle.Get the length of the
ucp_address_t*handle, required to access the complete address and prevent reading out-of-bound.- Returns:
The length of the
ucp_address_t*handle in bytes.
- std::string getString(
Get the address as a string.
Convenience method to copy the underlying address to a
std::stringand return it as a single object.- Returns:
The underlying
ucp_address_thandle.
Friends
- std::shared_ptr<Worker> worker
Constructor for
shared_ptr<ucxx::Address>from worker.The constructor for a
shared_ptr<ucxx::Address>object from astd::shared_ptr<ucxx::Worker>to obtain its address.- Parameters:
worker – [in] parent worker from which to get the address.
- Returns:
The
shared_ptr<ucxx::Address>object.
- friend std::shared_ptr<Address> createAddressFromString(
- std::string addressString
Constructor for
shared_ptr<ucxx::Address>from string.The constructor for a
shared_ptr<ucxx::Address>object from the address extracted as string from a remotestd::shared_ptr<ucxx::Worker>.- Parameters:
addressString – [in] the string from which to create the address.
- Returns:
The
shared_ptr<ucxx::Address>object.
Factory Functions#
#include <ucxx/constructors.h>
- std::shared_ptr<Worker> worker
The constructor for a
shared_ptr<ucxx::Address>object from astd::shared_ptr<ucxx::Worker>to obtain its address.- Parameters:
worker – [in] parent worker from which to get the address.
- Returns:
The
shared_ptr<ucxx::Address>object.
- std::shared_ptr<Address> ucxx::createAddressFromString(
- std::string addressString
The constructor for a
shared_ptr<ucxx::Address>object from the address extracted as string from a remotestd::shared_ptr<ucxx::Worker>.- Parameters:
addressString – [in] the string from which to create the address.
- Returns:
The
shared_ptr<ucxx::Address>object.