diff options
Diffstat (limited to 'source/Host/common/TCPSocket.cpp')
-rw-r--r-- | source/Host/common/TCPSocket.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp index 1a10336f1dfc5..58f99f7832fe2 100644 --- a/source/Host/common/TCPSocket.cpp +++ b/source/Host/common/TCPSocket.cpp @@ -1,9 +1,8 @@ //===-- TCPSocket.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,6 +17,7 @@ #include "lldb/Utility/Log.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/Errno.h" #include "llvm/Support/raw_ostream.h" #ifndef LLDB_DISABLE_POSIX @@ -118,6 +118,14 @@ std::string TCPSocket::GetRemoteIPAddress() const { return ""; } +std::string TCPSocket::GetRemoteConnectionURI() const { + if (m_socket != kInvalidSocketValue) { + return llvm::formatv("connect://[{0}]:{1}", GetRemoteIPAddress(), + GetRemotePortNumber()); + } + return ""; +} + Status TCPSocket::CreateSocket(int domain) { Status error; if (IsValid()) @@ -143,7 +151,7 @@ Status TCPSocket::Connect(llvm::StringRef name) { return error; auto addresses = lldb_private::SocketAddress::GetAddressInfo( - host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { error = CreateSocket(address.GetFamily()); if (error.Fail()) @@ -151,8 +159,8 @@ Status TCPSocket::Connect(llvm::StringRef name) { address.SetPort(port); - if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(), - address.GetLength())) { + if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, + GetNativeSocket(), &address.sockaddr(), address.GetLength())) { CLOSE_SOCKET(GetNativeSocket()); continue; } @@ -182,7 +190,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { if (host_str == "*") host_str = "0.0.0.0"; auto addresses = lldb_private::SocketAddress::GetAddressInfo( - host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); for (auto address : addresses) { int fd = Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, m_child_processes_inherit, error); |