1 //===-- Acceptor.h ----------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 #ifndef lldb_server_Acceptor_h_
9 #define lldb_server_Acceptor_h_
11 #include "lldb/Host/Socket.h"
12 #include "lldb/Utility/Connection.h"
13 #include "lldb/Utility/Status.h"
23 namespace lldb_private {
24 namespace lldb_server {
28 virtual ~Acceptor() = default;
30 Status Listen(int backlog);
32 Status Accept(const bool child_processes_inherit, Connection *&conn);
34 static std::unique_ptr<Acceptor> Create(llvm::StringRef name,
35 const bool child_processes_inherit,
38 Socket::SocketProtocol GetSocketProtocol() const;
40 const char *GetSocketScheme() const;
42 // Returns either TCP port number as string or domain socket path.
43 // Empty string is returned in case of error.
44 std::string GetLocalSocketId() const;
47 typedef std::function<std::string()> LocalSocketIdFunc;
49 Acceptor(std::unique_ptr<Socket> &&listener_socket, llvm::StringRef name,
50 const LocalSocketIdFunc &local_socket_id);
52 const std::unique_ptr<Socket> m_listener_socket_up;
53 const std::string m_name;
54 const LocalSocketIdFunc m_local_socket_id;
57 } // namespace lldb_server
58 } // namespace lldb_private
60 #endif // lldb_server_Acceptor_h_