summaryrefslogtreecommitdiff
path: root/source/Host/common/SocketAddress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/common/SocketAddress.cpp')
-rw-r--r--source/Host/common/SocketAddress.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp
index 41150fa7fd74a..def3e0359f016 100644
--- a/source/Host/common/SocketAddress.cpp
+++ b/source/Host/common/SocketAddress.cpp
@@ -317,6 +317,13 @@ bool SocketAddress::IsAnyAddr() const {
: 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_any, 16);
}
+bool SocketAddress::IsLocalhost() const {
+ return (GetFamily() == AF_INET)
+ ? m_socket_addr.sa_ipv4.sin_addr.s_addr == htonl(INADDR_LOOPBACK)
+ : 0 == memcmp(&m_socket_addr.sa_ipv6.sin6_addr, &in6addr_loopback,
+ 16);
+}
+
bool SocketAddress::operator==(const SocketAddress &rhs) const {
if (GetFamily() != rhs.GetFamily())
return false;