1 //===-- TCPSocket.h ---------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_TCPSocket_h_
10 #define liblldb_TCPSocket_h_
12 #include "lldb/Host/Socket.h"
13 #include "lldb/Host/SocketAddress.h"
16 namespace lldb_private {
17 class TCPSocket : public Socket {
19 TCPSocket(bool should_close, bool child_processes_inherit);
20 TCPSocket(NativeSocket socket, bool should_close,
21 bool child_processes_inherit);
22 ~TCPSocket() override;
24 // returns port number or 0 if error
25 uint16_t GetLocalPortNumber() const;
27 // returns ip address string or empty string if error
28 std::string GetLocalIPAddress() const;
31 // returns port number or 0 if error
32 uint16_t GetRemotePortNumber() const;
35 // returns ip address string or empty string if error
36 std::string GetRemoteIPAddress() const;
38 int SetOptionNoDelay();
39 int SetOptionReuseAddress();
41 Status Connect(llvm::StringRef name) override;
42 Status Listen(llvm::StringRef name, int backlog) override;
43 Status Accept(Socket *&conn_socket) override;
45 Status CreateSocket(int domain);
47 bool IsValid() const override;
49 std::string GetRemoteConnectionURI() const override;
52 TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
54 void CloseListenSockets();
56 std::map<int, SocketAddress> m_listen_sockets;
60 #endif // ifndef liblldb_TCPSocket_h_