1 //===-- TCPSocket.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_TCPSocket_h_
11 #define liblldb_TCPSocket_h_
13 #include "lldb/Host/Socket.h"
14 #include "lldb/Host/SocketAddress.h"
17 namespace lldb_private {
18 class TCPSocket : public Socket {
20 TCPSocket(bool should_close, bool child_processes_inherit);
21 TCPSocket(NativeSocket socket, bool should_close,
22 bool child_processes_inherit);
23 ~TCPSocket() override;
25 // returns port number or 0 if error
26 uint16_t GetLocalPortNumber() const;
28 // returns ip address string or empty string if error
29 std::string GetLocalIPAddress() const;
32 // returns port number or 0 if error
33 uint16_t GetRemotePortNumber() const;
36 // returns ip address string or empty string if error
37 std::string GetRemoteIPAddress() const;
39 int SetOptionNoDelay();
40 int SetOptionReuseAddress();
42 Status Connect(llvm::StringRef name) override;
43 Status Listen(llvm::StringRef name, int backlog) override;
44 Status Accept(Socket *&conn_socket) override;
46 Status CreateSocket(int domain);
48 bool IsValid() const override;
51 TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
53 void CloseListenSockets();
55 std::map<int, SocketAddress> m_listen_sockets;
59 #endif // ifndef liblldb_TCPSocket_h_