mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-30 23:51:34 +02:00
SocketAddress: constructor taking single string now also accepts a local socket path on UNIX platforms
This commit is contained in:
parent
5bde0dae76
commit
86f2094d09
@ -91,6 +91,10 @@ public:
|
||||
/// 192.168.1.10:80
|
||||
/// [::ffff:192.168.1.120]:2040
|
||||
/// 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);
|
||||
/// 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::const_iterator it = hostAndPort.begin();
|
||||
std::string::const_iterator end = hostAndPort.end();
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
if (*it == '/')
|
||||
{
|
||||
newLocal(hostAndPort);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (*it == '[')
|
||||
{
|
||||
++it;
|
||||
|
@ -170,6 +170,10 @@ void SocketAddressTest::testSocketAddressUnixLocal()
|
||||
SocketAddress sa3(SocketAddress::UNIX_LOCAL, "/tmp/sock1");
|
||||
assert (sa1 == sa3);
|
||||
assert (!(sa1 < sa3));
|
||||
|
||||
SocketAddress sa4("/tmp/sock1");
|
||||
assert (sa1 == sa4);
|
||||
assert (sa4.toString() == "/tmp/sock1");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user