1292932Sdim//===-- Acceptor.h ----------------------------------------------*- C++ -*-===// 2292932Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6292932Sdim// 7292932Sdim//===----------------------------------------------------------------------===// 8292932Sdim#ifndef lldb_server_Acceptor_h_ 9292932Sdim#define lldb_server_Acceptor_h_ 10292932Sdim 11292932Sdim#include "lldb/Host/Socket.h" 12321369Sdim#include "lldb/Utility/Connection.h" 13321369Sdim#include "lldb/Utility/Status.h" 14292932Sdim 15292932Sdim#include <functional> 16292932Sdim#include <memory> 17292932Sdim#include <string> 18292932Sdim 19314564Sdimnamespace llvm { 20314564Sdimclass StringRef; 21292932Sdim} 22292932Sdim 23292932Sdimnamespace lldb_private { 24292932Sdimnamespace lldb_server { 25292932Sdim 26314564Sdimclass Acceptor { 27292932Sdimpublic: 28314564Sdim virtual ~Acceptor() = default; 29292932Sdim 30321369Sdim Status Listen(int backlog); 31292932Sdim 32321369Sdim Status Accept(const bool child_processes_inherit, Connection *&conn); 33292932Sdim 34314564Sdim static std::unique_ptr<Acceptor> Create(llvm::StringRef name, 35314564Sdim const bool child_processes_inherit, 36321369Sdim Status &error); 37292932Sdim 38314564Sdim Socket::SocketProtocol GetSocketProtocol() const; 39292932Sdim 40314564Sdim const char *GetSocketScheme() const; 41292932Sdim 42314564Sdim // Returns either TCP port number as string or domain socket path. 43314564Sdim // Empty string is returned in case of error. 44314564Sdim std::string GetLocalSocketId() const; 45292932Sdim 46292932Sdimprivate: 47314564Sdim typedef std::function<std::string()> LocalSocketIdFunc; 48292932Sdim 49314564Sdim Acceptor(std::unique_ptr<Socket> &&listener_socket, llvm::StringRef name, 50314564Sdim const LocalSocketIdFunc &local_socket_id); 51292932Sdim 52314564Sdim const std::unique_ptr<Socket> m_listener_socket_up; 53314564Sdim const std::string m_name; 54314564Sdim const LocalSocketIdFunc m_local_socket_id; 55292932Sdim}; 56292932Sdim 57292932Sdim} // namespace lldb_server 58292932Sdim} // namespace lldb_private 59292932Sdim 60314564Sdim#endif // lldb_server_Acceptor_h_ 61