LLDB mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
lldb_private::Socket Class Referenceabstract

#include <Socket.h>

Inheritance diagram for lldb_private::Socket:
Inheritance graph
[legend]

Classes

struct  HostAndPort
 

Public Types

enum  SocketProtocol { ProtocolTcp , ProtocolUdp , ProtocolUnixDomain , ProtocolUnixAbstract }
 
- Public Types inherited from lldb_private::IOObject
enum  FDType { eFDTypeFile , eFDTypeSocket }
 
typedef int WaitableHandle
 

Public Member Functions

 ~Socket () override
 
virtual Status Connect (llvm::StringRef name)=0
 
virtual Status Listen (llvm::StringRef name, int backlog)=0
 
virtual Status Accept (Socket *&socket)=0
 
int GetOption (int level, int option_name, int &option_value)
 
int SetOption (int level, int option_name, int option_value)
 
NativeSocket GetNativeSocket () const
 
SocketProtocol GetSocketProtocol () const
 
Status Read (void *buf, size_t &num_bytes) override
 
Status Write (const void *buf, size_t &num_bytes) override
 
Status Close () override
 
bool IsValid () const override
 
WaitableHandle GetWaitableHandle () override
 
virtual std::string GetRemoteConnectionURI () const
 
- Public Member Functions inherited from lldb_private::IOObject
 IOObject (FDType type)
 
virtual ~IOObject ()
 
virtual Status Read (void *buf, size_t &num_bytes)=0
 
virtual Status Write (const void *buf, size_t &num_bytes)=0
 
virtual bool IsValid () const =0
 
virtual Status Close ()=0
 
FDType GetFdType () const
 
virtual WaitableHandle GetWaitableHandle ()=0
 

Static Public Member Functions

static const char * FindSchemeByProtocol (const SocketProtocol protocol)
 
static bool FindProtocolByScheme (const char *scheme, SocketProtocol &protocol)
 
static llvm::Error Initialize ()
 
static void Terminate ()
 
static std::unique_ptr< SocketCreate (const SocketProtocol protocol, bool child_processes_inherit, Status &error)
 
static llvm::Expected< std::unique_ptr< TCPSocket > > TcpListen (llvm::StringRef host_and_port, bool child_processes_inherit, int backlog=5)
 
static llvm::Expected< std::unique_ptr< Socket > > TcpConnect (llvm::StringRef host_and_port, bool child_processes_inherit)
 
static llvm::Expected< std::unique_ptr< UDPSocket > > UdpConnect (llvm::StringRef host_and_port, bool child_processes_inherit)
 
static llvm::Expected< HostAndPortDecodeHostAndPort (llvm::StringRef host_and_port)
 

Static Public Attributes

static const NativeSocket kInvalidSocketValue = -1
 
- Static Public Attributes inherited from lldb_private::IOObject
static const WaitableHandle kInvalidHandleValue = -1
 

Protected Member Functions

 Socket (SocketProtocol protocol, bool should_close, bool m_child_process_inherit)
 
virtual size_t Send (const void *buf, const size_t num_bytes)
 

Static Protected Member Functions

static void SetLastError (Status &error)
 
static NativeSocket CreateSocket (const int domain, const int type, const int protocol, bool child_processes_inherit, Status &error)
 
static NativeSocket AcceptSocket (NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit, Status &error)
 

Protected Attributes

SocketProtocol m_protocol
 
NativeSocket m_socket
 
bool m_child_processes_inherit
 
bool m_should_close_fd
 
- Protected Attributes inherited from lldb_private::IOObject
FDType m_fd_type
 

Detailed Description

Definition at line 41 of file Socket.h.

Member Enumeration Documentation

◆ SocketProtocol

Enumerator
ProtocolTcp 
ProtocolUdp 
ProtocolUnixDomain 
ProtocolUnixAbstract 

Definition at line 43 of file Socket.h.

Constructor & Destructor Documentation

◆ ~Socket()

Socket::~Socket ( )
override

Definition at line 112 of file Socket.cpp.

References Close().

◆ Socket()

Socket::Socket ( SocketProtocol  protocol,
bool  should_close,
bool  m_child_process_inherit 
)
protected

Definition at line 105 of file Socket.cpp.

Member Function Documentation

◆ Accept()

virtual Status lldb_private::Socket::Accept ( Socket *&  socket)
pure virtual

◆ AcceptSocket()

NativeSocket Socket::AcceptSocket ( NativeSocket  sockfd,
struct sockaddr *  addr,
socklen_t *  addrlen,
bool  child_processes_inherit,
Status error 
)
staticprotected

Definition at line 369 of file Socket.cpp.

References error(), kInvalidSocketValue, and SetLastError().

Referenced by lldb_private::DomainSocket::Accept().

◆ Close()

Status Socket::Close ( )
overridevirtual

◆ Connect()

virtual Status lldb_private::Socket::Connect ( llvm::StringRef  name)
pure virtual

◆ Create()

std::unique_ptr< Socket > Socket::Create ( const SocketProtocol  protocol,
bool  child_processes_inherit,
Status error 
)
static

◆ CreateSocket()

NativeSocket Socket::CreateSocket ( const int  domain,
const int  type,
const int  protocol,
bool  child_processes_inherit,
Status error 
)
staticprotected

◆ DecodeHostAndPort()

llvm::Expected< Socket::HostAndPort > Socket::DecodeHostAndPort ( llvm::StringRef  host_and_port)
static

◆ FindProtocolByScheme()

bool Socket::FindProtocolByScheme ( const char *  scheme,
Socket::SocketProtocol protocol 
)
static

Definition at line 94 of file Socket.cpp.

References socket_schemes.

◆ FindSchemeByProtocol()

const char * Socket::FindSchemeByProtocol ( const SocketProtocol  protocol)
static

Definition at line 86 of file Socket.cpp.

References socket_schemes.

◆ GetNativeSocket()

NativeSocket lldb_private::Socket::GetNativeSocket ( ) const
inline

◆ GetOption()

int Socket::GetOption ( int  level,
int  option_name,
int &  option_value 
)

Definition at line 326 of file Socket.cpp.

References m_socket.

◆ GetRemoteConnectionURI()

virtual std::string lldb_private::Socket::GetRemoteConnectionURI ( ) const
inlinevirtual

◆ GetSocketProtocol()

SocketProtocol lldb_private::Socket::GetSocketProtocol ( ) const
inline

Definition at line 95 of file Socket.h.

References m_protocol.

◆ GetWaitableHandle()

IOObject::WaitableHandle Socket::GetWaitableHandle ( )
overridevirtual

Implements lldb_private::IOObject.

Definition at line 243 of file Socket.cpp.

References m_socket.

◆ Initialize()

llvm::Error Socket::Initialize ( )
static

Definition at line 114 of file Socket.cpp.

Referenced by lldb_private::SystemInitializerCommon::Initialize().

◆ IsValid()

bool lldb_private::Socket::IsValid ( ) const
inlineoverridevirtual

Implements lldb_private::IOObject.

Definition at line 102 of file Socket.h.

References kInvalidSocketValue, and m_socket.

Referenced by Close().

◆ Listen()

virtual Status lldb_private::Socket::Listen ( llvm::StringRef  name,
int  backlog 
)
pure virtual

◆ Read()

Status Socket::Read ( void *  buf,
size_t &  num_bytes 
)
overridevirtual

◆ Send()

size_t Socket::Send ( const void *  buf,
const size_t  num_bytes 
)
protectedvirtual

Reimplemented in lldb_private::UDPSocket.

Definition at line 341 of file Socket.cpp.

References m_socket.

Referenced by Write().

◆ SetLastError()

void Socket::SetLastError ( Status error)
staticprotected

◆ SetOption()

int Socket::SetOption ( int  level,
int  option_name,
int  option_value 
)

◆ TcpConnect()

llvm::Expected< std::unique_ptr< Socket > > Socket::TcpConnect ( llvm::StringRef  host_and_port,
bool  child_processes_inherit 
)
static

◆ TcpListen()

llvm::Expected< std::unique_ptr< TCPSocket > > Socket::TcpListen ( llvm::StringRef  host_and_port,
bool  child_processes_inherit,
int  backlog = 5 
)
static

Definition at line 199 of file Socket.cpp.

References lldb_private::Connection, error(), lldb_private::GetLog(), and LLDB_LOG.

◆ Terminate()

void Socket::Terminate ( )
static

Definition at line 132 of file Socket.cpp.

Referenced by lldb_private::SystemInitializerCommon::Terminate().

◆ UdpConnect()

llvm::Expected< std::unique_ptr< UDPSocket > > Socket::UdpConnect ( llvm::StringRef  host_and_port,
bool  child_processes_inherit 
)
static

◆ Write()

Status Socket::Write ( const void *  buf,
size_t &  num_bytes 
)
overridevirtual

Member Data Documentation

◆ kInvalidSocketValue

const NativeSocket Socket::kInvalidSocketValue = -1
static

◆ m_child_processes_inherit

bool lldb_private::Socket::m_child_processes_inherit
protected

◆ m_protocol

SocketProtocol lldb_private::Socket::m_protocol
protected

Definition at line 125 of file Socket.h.

Referenced by GetSocketProtocol().

◆ m_should_close_fd

bool lldb_private::Socket::m_should_close_fd
protected

Definition at line 128 of file Socket.h.

Referenced by Close().

◆ m_socket

NativeSocket lldb_private::Socket::m_socket
protected

The documentation for this class was generated from the following files: