LLDB mainline
|
#include <TCPSocket.h>
Public Member Functions | |
TCPSocket (bool should_close) | |
TCPSocket (NativeSocket socket, bool should_close) | |
~TCPSocket () override | |
uint16_t | GetLocalPortNumber () const |
std::string | GetLocalIPAddress () const |
uint16_t | GetRemotePortNumber () const |
std::string | GetRemoteIPAddress () const |
int | SetOptionNoDelay () |
int | SetOptionReuseAddress () |
Status | Connect (llvm::StringRef name) override |
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 |
Status | CreateSocket (int domain) |
bool | IsValid () const override |
std::string | GetRemoteConnectionURI () const override |
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 |
virtual Status | Accept (const Timeout< std::micro > &timeout, Socket *&socket) |
![]() | |
~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 |
![]() | |
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 |
Private Member Functions | |
TCPSocket (NativeSocket socket, const TCPSocket &listen_socket) | |
void | CloseListenSockets () |
Private Attributes | |
std::map< int, SocketAddress > | m_listen_sockets |
Additional Inherited Members | |
![]() | |
enum | SocketProtocol { ProtocolTcp , ProtocolUdp , ProtocolUnixDomain , ProtocolUnixAbstract } |
![]() | |
enum | FDType { eFDTypeFile , eFDTypeSocket } |
typedef int | WaitableHandle |
![]() | |
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< Socket > | Create (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< HostAndPort > | DecodeHostAndPort (llvm::StringRef host_and_port) |
![]() | |
static const NativeSocket | kInvalidSocketValue = -1 |
![]() | |
static const WaitableHandle | kInvalidHandleValue = -1 |
![]() | |
Socket (SocketProtocol protocol, bool should_close) | |
virtual size_t | Send (const void *buf, const size_t num_bytes) |
![]() | |
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) |
![]() | |
SocketProtocol | m_protocol |
NativeSocket | m_socket |
bool | m_should_close_fd |
![]() | |
FDType | m_fd_type |
Definition at line 20 of file TCPSocket.h.
|
explicit |
Definition at line 41 of file TCPSocket.cpp.
TCPSocket::TCPSocket | ( | NativeSocket | socket, |
bool | should_close | ||
) |
Definition at line 48 of file TCPSocket.cpp.
References lldb_private::Socket::m_socket.
|
override |
Definition at line 53 of file TCPSocket.cpp.
References CloseListenSockets().
|
private |
Definition at line 43 of file TCPSocket.cpp.
References lldb_private::Socket::m_socket.
Reimplemented from lldb_private::Socket.
Definition at line 112 of file Socket.cpp.
|
overridevirtual |
Implements lldb_private::Socket.
Definition at line 240 of file TCPSocket.cpp.
References lldb_private::Socket::AcceptSocket(), lldb_private::Socket::CloseSocket(), error(), lldb_private::SocketAddress::GetIPAddress(), lldb_private::GetLog(), lldb_private::SocketAddress::GetMaxLength(), lldb_private::Host, lldb_private::SocketAddress::IsAnyAddr(), LLDB_LOG, m_listen_sockets, lldb_private::MainLoopBase::RegisterReadObject(), and lldb_private::SocketAddress::sockaddr().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::ConnectLocally().
|
virtual |
Implements lldb_private::Socket.
|
private |
Definition at line 233 of file TCPSocket.cpp.
References lldb_private::Socket::CloseSocket(), and m_listen_sockets.
Referenced by ~TCPSocket().
|
overridevirtual |
Implements lldb_private::Socket.
Definition at line 136 of file TCPSocket.cpp.
References lldb_private::Socket::Close(), lldb_private::Communication, CreateSocket(), lldb_private::Socket::DecodeHostAndPort(), error(), lldb_private::Status::FromError(), lldb_private::Status::FromErrorString(), lldb_private::SocketAddress::GetAddressInfo(), lldb_private::GetLog(), lldb_private::Socket::GetNativeSocket(), LLDB_LOG, and SetOptionNoDelay().
Status TCPSocket::CreateSocket | ( | int | domain | ) |
Definition at line 126 of file TCPSocket.cpp.
References lldb_private::Socket::Close(), lldb_private::Socket::CreateSocket(), error(), IsValid(), kType, and lldb_private::Socket::m_socket.
Referenced by Connect().
|
overridevirtual |
Reimplemented from lldb_private::Socket.
Definition at line 118 of file TCPSocket.cpp.
References m_listen_sockets.
std::string TCPSocket::GetLocalIPAddress | ( | ) | const |
Definition at line 76 of file TCPSocket.cpp.
References lldb_private::SocketAddress::GetIPAddress(), lldb_private::SocketAddress::GetMaxLength(), lldb_private::Socket::kInvalidSocketValue, and lldb_private::Socket::m_socket.
uint16_t TCPSocket::GetLocalPortNumber | ( | ) | const |
Definition at line 60 of file TCPSocket.cpp.
References lldb_private::SocketAddress::GetMaxLength(), lldb_private::SocketAddress::GetPort(), lldb_private::Socket::kInvalidSocketValue, m_listen_sockets, and lldb_private::Socket::m_socket.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::ConnectLocally(), and ProcessKDP::DoConnectRemote().
|
overridevirtual |
Reimplemented from lldb_private::Socket.
Definition at line 110 of file TCPSocket.cpp.
References GetRemoteIPAddress(), GetRemotePortNumber(), lldb_private::Socket::kInvalidSocketValue, and lldb_private::Socket::m_socket.
Referenced by lldb_private::ConnectionFileDescriptor::AcceptTCP().
std::string TCPSocket::GetRemoteIPAddress | ( | ) | const |
Definition at line 98 of file TCPSocket.cpp.
References lldb_private::SocketAddress::GetIPAddress(), lldb_private::SocketAddress::GetMaxLength(), lldb_private::Socket::kInvalidSocketValue, and lldb_private::Socket::m_socket.
Referenced by GetRemoteConnectionURI().
uint16_t TCPSocket::GetRemotePortNumber | ( | ) | const |
Definition at line 88 of file TCPSocket.cpp.
References lldb_private::SocketAddress::GetMaxLength(), lldb_private::SocketAddress::GetPort(), lldb_private::Socket::kInvalidSocketValue, and lldb_private::Socket::m_socket.
Referenced by GetRemoteConnectionURI().
|
overridevirtual |
Implements lldb_private::IOObject.
Definition at line 55 of file TCPSocket.cpp.
References lldb_private::Socket::kInvalidSocketValue, m_listen_sockets, and lldb_private::Socket::m_socket.
Referenced by CreateSocket().
|
overridevirtual |
Implements lldb_private::Socket.
Definition at line 176 of file TCPSocket.cpp.
References lldb_private::Socket::CloseSocket(), lldb_private::Connection, lldb_private::Socket::CreateSocket(), lldb_private::Socket::DecodeHostAndPort(), error(), lldb_private::Status::FromError(), lldb_private::SocketAddress::GetAddressInfo(), lldb_private::Socket::GetLastError(), lldb_private::SocketAddress::GetLength(), lldb_private::GetLog(), lldb_private::SocketAddress::GetPort(), lldb_private::SocketAddress::IsLocalhost(), kType, LLDB_LOG, m_listen_sockets, lldb_private::Socket::SetOption(), lldb_private::SocketAddress::SetPort(), lldb_private::SocketAddress::SetToAnyAddress(), and lldb_private::SocketAddress::sockaddr().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunication::ConnectLocally().
int TCPSocket::SetOptionNoDelay | ( | ) |
Definition at line 284 of file TCPSocket.cpp.
References lldb_private::Socket::SetOption().
Referenced by Connect().
int TCPSocket::SetOptionReuseAddress | ( | ) |
Definition at line 288 of file TCPSocket.cpp.
References lldb_private::Socket::SetOption().
|
private |
Definition at line 64 of file TCPSocket.h.
Referenced by Accept(), CloseListenSockets(), GetListeningConnectionURI(), GetLocalPortNumber(), IsValid(), and Listen().