1061da546Spatrick //===-- Acceptor.h ----------------------------------------------*- C++ -*-===// 2061da546Spatrick // 3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6061da546Spatrick // 7061da546Spatrick //===----------------------------------------------------------------------===// 8*dda28197Spatrick #ifndef LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H 9*dda28197Spatrick #define LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H 10061da546Spatrick 11061da546Spatrick #include "lldb/Host/Socket.h" 12061da546Spatrick #include "lldb/Utility/Connection.h" 13061da546Spatrick #include "lldb/Utility/Status.h" 14061da546Spatrick 15061da546Spatrick #include <functional> 16061da546Spatrick #include <memory> 17061da546Spatrick #include <string> 18061da546Spatrick 19061da546Spatrick namespace llvm { 20061da546Spatrick class StringRef; 21061da546Spatrick } 22061da546Spatrick 23061da546Spatrick namespace lldb_private { 24061da546Spatrick namespace lldb_server { 25061da546Spatrick 26061da546Spatrick class Acceptor { 27061da546Spatrick public: 28061da546Spatrick virtual ~Acceptor() = default; 29061da546Spatrick 30061da546Spatrick Status Listen(int backlog); 31061da546Spatrick 32061da546Spatrick Status Accept(const bool child_processes_inherit, Connection *&conn); 33061da546Spatrick 34061da546Spatrick static std::unique_ptr<Acceptor> Create(llvm::StringRef name, 35061da546Spatrick const bool child_processes_inherit, 36061da546Spatrick Status &error); 37061da546Spatrick 38061da546Spatrick Socket::SocketProtocol GetSocketProtocol() const; 39061da546Spatrick 40061da546Spatrick const char *GetSocketScheme() const; 41061da546Spatrick 42061da546Spatrick // Returns either TCP port number as string or domain socket path. 43061da546Spatrick // Empty string is returned in case of error. 44061da546Spatrick std::string GetLocalSocketId() const; 45061da546Spatrick 46061da546Spatrick private: 47061da546Spatrick typedef std::function<std::string()> LocalSocketIdFunc; 48061da546Spatrick 49061da546Spatrick Acceptor(std::unique_ptr<Socket> &&listener_socket, llvm::StringRef name, 50061da546Spatrick const LocalSocketIdFunc &local_socket_id); 51061da546Spatrick 52061da546Spatrick const std::unique_ptr<Socket> m_listener_socket_up; 53061da546Spatrick const std::string m_name; 54061da546Spatrick const LocalSocketIdFunc m_local_socket_id; 55061da546Spatrick }; 56061da546Spatrick 57061da546Spatrick } // namespace lldb_server 58061da546Spatrick } // namespace lldb_private 59061da546Spatrick 60*dda28197Spatrick #endif // LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H 61