aboutsummaryrefslogtreecommitdiffstats
path: root/source/Host/common/TCPSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/common/TCPSocket.cpp')
-rw-r--r--source/Host/common/TCPSocket.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp
index a7af93f10a7f..f896944bb1b3 100644
--- a/source/Host/common/TCPSocket.cpp
+++ b/source/Host/common/TCPSocket.cpp
@@ -198,9 +198,14 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
sizeof(option_value));
- address.SetPort(port);
-
- int err = ::bind(fd, &address.sockaddr(), address.GetLength());
+ SocketAddress listen_address = address;
+ if(!listen_address.IsLocalhost())
+ listen_address.SetToAnyAddress(address.GetFamily(), port);
+ else
+ listen_address.SetPort(port);
+
+ int err =
+ ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
if (-1 != err)
err = ::listen(fd, backlog);