summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/Socket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/common/Socket.cpp')
-rw-r--r--lldb/source/Host/common/Socket.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 6620dab123b..37b6cd5aaa7 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -201,12 +201,12 @@ Error Socket::TcpConnect(llvm::StringRef host_and_port, bool child_processes_inh
return error;
}
-Error Socket::TcpListen(
- llvm::StringRef host_and_port,
- bool child_processes_inherit,
- Socket *&socket,
- Predicate<uint16_t>* predicate,
- int backlog)
+Error
+Socket::TcpListen (llvm::StringRef host_and_port,
+ bool child_processes_inherit,
+ Socket *&socket,
+ Predicate<uint16_t>* predicate,
+ int backlog)
{
std::unique_ptr<Socket> listen_socket;
NativeSocket listen_sock = kInvalidSocketValue;
@@ -237,10 +237,19 @@ Error Socket::TcpListen(
if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
return error;
- SocketAddress anyaddr;
- if (anyaddr.SetToAnyAddress (family, port))
+ SocketAddress bind_addr;
+ bool bind_addr_success = false;
+
+ // Only bind to the loopback address if we are expecting a connection from
+ // localhost to avoid any firewall issues.
+ if (host_str == "127.0.0.1")
+ bind_addr_success = bind_addr.SetToLocalhost (family, port);
+ else
+ bind_addr_success = bind_addr.SetToAnyAddress (family, port);
+
+ if (bind_addr_success)
{
- int err = ::bind (listen_sock, anyaddr, anyaddr.GetLength());
+ int err = ::bind (listen_sock, bind_addr, bind_addr.GetLength());
if (err == -1)
{
SetLastError (error);
OpenPOWER on IntegriCloud