21#if defined(YARP_HAS_ACE)
22# include <ace/INET_Addr.h>
28# include <arpa/inet.h>
29# include <sys/socket.h>
30# include <sys/types.h>
41#if !defined(YARP_HAS_ACE)
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
52 Private(std::string regName,
56 regName(
std::move(regName)),
57 carrier(
std::move(carrier)),
58 hostname(
std::move(hostname)),
78 mPriv(
new Private(
std::string(),
std::string(), hostname, port))
83 const std::string& hostname,
85 mPriv(
new Private(
std::string(), carrier, hostname, port))
90 const std::string& carrier,
91 const std::string& hostname,
93 mPriv(
new Private(name, carrier, hostname, port))
98 mPriv(
new Private(*(
rhs.mPriv)))
116 *mPriv = *(
rhs.mPriv);
124 std::swap(mPriv,
rhs.mPriv);
132 result.mPriv->port = config.
check(
"port_number",
Value(-1)).asInt32();
133 result.mPriv->hostname = config.
check(
"ip",
Value(
"")).asString();
134 result.mPriv->regName = config.
check(
"name",
Value(
"")).asString();
135 result.mPriv->carrier = config.
check(
"carrier",
Value(
"tcp")).asString();
141 std::string str(txt);
143 std::string::size_type start = 0;
144 std::string::size_type base = str.find(
"://");
145 std::string::size_type offset = 2;
146 if (base == std::string::npos) {
147 base = str.find(
":/");
150 if (base == std::string::npos) {
151 if (str.length() > 0 && str[0] ==
'/') {
156 if (base != std::string::npos) {
157 c.mPriv->carrier = str.substr(0, base);
158 start = base + offset;
160 std::string::size_type
colon = std::string::npos;
163 std::string::size_type
i;
164 for (
i = start + 1;
i < str.length();
i++) {
179 if (ch >=
'0' && ch <=
'9') {
187 if (mode == 1 &&
nums >= 1) {
189 if (
c.mPriv->carrier.empty()) {
190 c.mPriv->carrier =
"tcp";
192 c.mPriv->hostname = str.substr(start + 1,
colon - start - 1);
197 std::string
rname = str.substr(start);
207 if (!mPriv->regName.empty()) {
208 return mPriv->regName;
210 if (!mPriv->hostname.empty() && mPriv->port >= 0) {
219 return mPriv->regName;
224 mPriv->regName = name;
230 return mPriv->hostname;
235 this->mPriv->hostname = hostname;
252 return mPriv->carrier;
257 mPriv->carrier = carrier;
263 return mPriv->nestedContact;
274 return mPriv->timeout >= 0;
279 return mPriv->timeout;
284 this->mPriv->timeout = timeout;
289 const std::string& hostname,
292 mPriv->carrier = carrier;
293 mPriv->hostname = hostname;
300 return mPriv->port >= 0;
306 if (!mPriv->carrier.empty()) {
307 return mPriv->carrier +
":/" + name;
317 result += mPriv->carrier;
320 if (!mPriv->hostname.empty() && mPriv->port >= 0) {
322 result += mPriv->hostname;
333#if defined(YARP_HAS_ACE)
348 if ((status = yarp::os::impl::getaddrinfo(name,
"http", &
hints, &
res)) != 0) {
349 yCError(
CONTACT,
"getaddrinfo error: %s\n", yarp::os::impl::gai_strerror(status));
353 for (
p =
res;
p !=
nullptr;
p =
p->ai_next) {
367 yarp::os::impl::freeaddrinfo(
res);
370 if (NameConfig::isLocalName(
ipstr)) {
371 return NameConfig::getHostName();
A mini-server for performing network communication in the background.
Various utilities related to types and formats.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
Small helper class to help deal with legacy YARP configuration files.
#define yCError(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::string to_string(IntegerType x)