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 llvm::Expected< std::vector< MainLoopBase::ReadHandleUP > > Accept (MainLoopBase &loop, std::function< void(std::unique_ptr< Socket > socket)> sock_cb)=0
 
virtual Status Accept (const Timeout< std::micro > &timeout, Socket *&socket)
 
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
 
virtual std::vector< std::string > GetListeningConnectionURI () 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, Status &error)
 
static llvm::Expected< std::unique_ptr< TCPSocket > > TcpListen (llvm::StringRef host_and_port, int backlog=5)
 
static llvm::Expected< std::unique_ptr< Socket > > TcpConnect (llvm::StringRef host_and_port)
 
static llvm::Expected< std::unique_ptr< UDPSocket > > UdpConnect (llvm::StringRef host_and_port)
 
static int GetOption (NativeSocket sockfd, int level, int option_name, int &option_value)
 
static int SetOption (NativeSocket sockfd, int level, int option_name, int option_value)
 
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)
 
virtual size_t Send (const void *buf, const size_t num_bytes)
 

Static Protected Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 68 of file Socket.h.

Member Enumeration Documentation

◆ SocketProtocol

Enumerator
ProtocolTcp 
ProtocolUdp 
ProtocolUnixDomain 
ProtocolUnixAbstract 

Definition at line 70 of file Socket.h.

Constructor & Destructor Documentation

◆ ~Socket()

Socket::~Socket ( )
override

Definition at line 187 of file Socket.cpp.

References Close().

◆ Socket()

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

Definition at line 183 of file Socket.cpp.

Member Function Documentation

◆ Accept() [1/2]

Status Socket::Accept ( const Timeout< std::micro > &  timeout,
Socket *&  socket 
)
virtual

◆ Accept() [2/2]

virtual llvm::Expected< std::vector< MainLoopBase::ReadHandleUP > > lldb_private::Socket::Accept ( MainLoopBase loop,
std::function< void(std::unique_ptr< Socket > socket)>  sock_cb 
)
pure virtual

◆ AcceptSocket()

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

◆ Close()

Status Socket::Close ( )
overridevirtual

◆ CloseSocket()

int Socket::CloseSocket ( NativeSocket  sockfd)
staticprotected

◆ Connect()

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

◆ Create()

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

◆ CreateSocket()

NativeSocket Socket::CreateSocket ( const int  domain,
const int  type,
const int  protocol,
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 172 of file Socket.cpp.

References socket_schemes.

◆ FindSchemeByProtocol()

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

◆ GetLastError()

Status Socket::GetLastError ( )
staticprotected

Definition at line 418 of file Socket.cpp.

Referenced by lldb_private::TCPSocket::Listen().

◆ GetListeningConnectionURI()

virtual std::vector< std::string > lldb_private::Socket::GetListeningConnectionURI ( ) const
inlinevirtual

Reimplemented in lldb_private::TCPSocket, and lldb_private::DomainSocket.

Definition at line 156 of file Socket.h.

◆ GetNativeSocket()

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

◆ GetOption() [1/2]

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

Definition at line 128 of file Socket.h.

References GetOption(), and m_socket.

◆ GetOption() [2/2]

int Socket::GetOption ( NativeSocket  sockfd,
int  level,
int  option_name,
int &  option_value 
)
static

Definition at line 389 of file Socket.cpp.

Referenced by GetOption().

◆ GetRemoteConnectionURI()

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

◆ GetSocketProtocol()

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

Definition at line 139 of file Socket.h.

References m_protocol.

◆ GetWaitableHandle()

IOObject::WaitableHandle Socket::GetWaitableHandle ( )
overridevirtual

Implements lldb_private::IOObject.

Definition at line 310 of file Socket.cpp.

References m_socket.

◆ Initialize()

llvm::Error Socket::Initialize ( )
static

Definition at line 189 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 146 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 406 of file Socket.cpp.

References m_socket.

Referenced by Write().

◆ SetLastError()

void Socket::SetLastError ( Status error)
staticprotected

◆ SetOption() [1/2]

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

Definition at line 134 of file Socket.h.

References m_socket, and SetOption().

◆ SetOption() [2/2]

int Socket::SetOption ( NativeSocket  sockfd,
int  level,
int  option_name,
int  option_value 
)
static

◆ TcpConnect()

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

◆ TcpListen()

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

Definition at line 268 of file Socket.cpp.

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

◆ Terminate()

void Socket::Terminate ( )
static

Definition at line 207 of file Socket.cpp.

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

◆ UdpConnect()

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

◆ Write()

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

Member Data Documentation

◆ kInvalidSocketValue

const NativeSocket Socket::kInvalidSocketValue = -1
static

◆ m_protocol

SocketProtocol lldb_private::Socket::m_protocol
protected

Definition at line 173 of file Socket.h.

Referenced by GetSocketProtocol().

◆ m_should_close_fd

bool lldb_private::Socket::m_should_close_fd
protected

Definition at line 175 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: