LLDB mainline
DomainSocket.h
Go to the documentation of this file.
1//===-- DomainSocket.h ------------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_HOST_POSIX_DOMAINSOCKET_H
10#define LLDB_HOST_POSIX_DOMAINSOCKET_H
11
12#include "lldb/Host/Socket.h"
13#include <string>
14#include <vector>
15
16namespace lldb_private {
17class DomainSocket : public Socket {
18public:
19 DomainSocket(NativeSocket socket, bool should_close);
20 explicit DomainSocket(bool should_close);
21
22 using Pair =
23 std::pair<std::unique_ptr<DomainSocket>, std::unique_ptr<DomainSocket>>;
24 static llvm::Expected<Pair> CreatePair();
25
26 Status Connect(llvm::StringRef name) override;
27 Status Listen(llvm::StringRef name, int backlog) override;
28
29 using Socket::Accept;
30 llvm::Expected<std::vector<MainLoopBase::ReadHandleUP>>
31 Accept(MainLoopBase &loop,
32 std::function<void(std::unique_ptr<Socket> socket)> sock_cb) override;
33
34 std::string GetRemoteConnectionURI() const override;
35
36 std::vector<std::string> GetListeningConnectionURI() const override;
37
38 static llvm::Expected<std::unique_ptr<DomainSocket>>
39 FromBoundNativeSocket(NativeSocket sockfd, bool should_close);
40
41protected:
43 DomainSocket(SocketProtocol protocol, NativeSocket socket, bool should_close);
44
45 virtual size_t GetNameOffset() const;
46 virtual void DeleteSocketFile(llvm::StringRef name);
47 std::string GetSocketName() const;
48
49private:
50 DomainSocket(NativeSocket socket, const DomainSocket &listen_socket);
51};
52}
53
54#endif // LLDB_HOST_POSIX_DOMAINSOCKET_H
DomainSocket(NativeSocket socket, bool should_close)
Status Listen(llvm::StringRef name, int backlog) override
llvm::Expected< std::vector< MainLoopBase::ReadHandleUP > > Accept(MainLoopBase &loop, std::function< void(std::unique_ptr< Socket > socket)> sock_cb) override
std::pair< std::unique_ptr< DomainSocket >, std::unique_ptr< DomainSocket > > Pair
virtual size_t GetNameOffset() const
virtual void DeleteSocketFile(llvm::StringRef name)
Status Connect(llvm::StringRef name) override
static llvm::Expected< std::unique_ptr< DomainSocket > > FromBoundNativeSocket(NativeSocket sockfd, bool should_close)
std::string GetSocketName() const
std::string GetRemoteConnectionURI() const override
static llvm::Expected< Pair > CreatePair()
std::vector< std::string > GetListeningConnectionURI() const override
virtual llvm::Expected< std::vector< MainLoopBase::ReadHandleUP > > Accept(MainLoopBase &loop, std::function< void(std::unique_ptr< Socket > socket)> sock_cb)=0
Socket(SocketProtocol protocol, bool should_close)
Definition Socket.cpp:170
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.
int NativeSocket
Definition Socket.h:41