LLDB mainline
TCPSocket.h
Go to the documentation of this file.
1//===-- TCPSocket.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_COMMON_TCPSOCKET_H
10#define LLDB_HOST_COMMON_TCPSOCKET_H
11
12#include "lldb/Host/Socket.h"
14#include <map>
15
16namespace lldb_private {
17class TCPSocket : public Socket {
18public:
19 TCPSocket(bool should_close, bool child_processes_inherit);
20 TCPSocket(NativeSocket socket, bool should_close,
21 bool child_processes_inherit);
22 ~TCPSocket() override;
23
24 // returns port number or 0 if error
25 uint16_t GetLocalPortNumber() const;
26
27 // returns ip address string or empty string if error
28 std::string GetLocalIPAddress() const;
29
30 // must be connected
31 // returns port number or 0 if error
32 uint16_t GetRemotePortNumber() const;
33
34 // must be connected
35 // returns ip address string or empty string if error
36 std::string GetRemoteIPAddress() const;
37
38 int SetOptionNoDelay();
40
41 Status Connect(llvm::StringRef name) override;
42 Status Listen(llvm::StringRef name, int backlog) override;
43 Status Accept(Socket *&conn_socket) override;
44
45 Status CreateSocket(int domain);
46
47 bool IsValid() const override;
48
49 std::string GetRemoteConnectionURI() const override;
50
51private:
52 TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
53
54 void CloseListenSockets();
55
56 std::map<int, SocketAddress> m_listen_sockets;
57};
58}
59
60#endif // LLDB_HOST_COMMON_TCPSOCKET_H
An error handling class.
Definition: Status.h:44
Status Listen(llvm::StringRef name, int backlog) override
Definition: TCPSocket.cpp:190
bool IsValid() const override
Definition: TCPSocket.cpp:76
Status Accept(Socket *&conn_socket) override
Definition: TCPSocket.cpp:257
uint16_t GetRemotePortNumber() const
Definition: TCPSocket.cpp:109
Status CreateSocket(int domain)
Definition: TCPSocket.cpp:139
std::string GetRemoteConnectionURI() const override
Definition: TCPSocket.cpp:131
std::string GetLocalIPAddress() const
Definition: TCPSocket.cpp:97
std::string GetRemoteIPAddress() const
Definition: TCPSocket.cpp:119
uint16_t GetLocalPortNumber() const
Definition: TCPSocket.cpp:81
std::map< int, SocketAddress > m_listen_sockets
Definition: TCPSocket.h:56
Status Connect(llvm::StringRef name) override
Definition: TCPSocket.cpp:150
A class that represents a running process on the host machine.
int NativeSocket
Definition: Socket.h:36