mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
SocketAddress: constructor taking single string now also accepts a local socket path on UNIX platforms
This commit is contained in:
@@ -91,6 +91,10 @@ public:
|
|||||||
/// 192.168.1.10:80
|
/// 192.168.1.10:80
|
||||||
/// [::ffff:192.168.1.120]:2040
|
/// [::ffff:192.168.1.120]:2040
|
||||||
/// www.appinf.com:8080
|
/// www.appinf.com:8080
|
||||||
|
///
|
||||||
|
/// On POSIX platforms supporting UNIX_LOCAL sockets, hostAndPort
|
||||||
|
/// can also be the absolute path of a local socket, starting with a
|
||||||
|
/// slash, e.g. "/tmp/local.socket".
|
||||||
|
|
||||||
SocketAddress(Family family, const std::string& addr);
|
SocketAddress(Family family, const std::string& addr);
|
||||||
/// Creates a SocketAddress of the given family from a
|
/// Creates a SocketAddress of the given family from a
|
||||||
|
|||||||
@@ -285,6 +285,14 @@ void SocketAddress::init(const std::string& hostAndPort)
|
|||||||
std::string port;
|
std::string port;
|
||||||
std::string::const_iterator it = hostAndPort.begin();
|
std::string::const_iterator it = hostAndPort.begin();
|
||||||
std::string::const_iterator end = hostAndPort.end();
|
std::string::const_iterator end = hostAndPort.end();
|
||||||
|
|
||||||
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
|
if (*it == '/')
|
||||||
|
{
|
||||||
|
newLocal(hostAndPort);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (*it == '[')
|
if (*it == '[')
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ void SocketAddressTest::testSocketAddressUnixLocal()
|
|||||||
SocketAddress sa3(SocketAddress::UNIX_LOCAL, "/tmp/sock1");
|
SocketAddress sa3(SocketAddress::UNIX_LOCAL, "/tmp/sock1");
|
||||||
assert (sa1 == sa3);
|
assert (sa1 == sa3);
|
||||||
assert (!(sa1 < sa3));
|
assert (!(sa1 < sa3));
|
||||||
|
|
||||||
|
SocketAddress sa4("/tmp/sock1");
|
||||||
|
assert (sa1 == sa4);
|
||||||
|
assert (sa4.toString() == "/tmp/sock1");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user