Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:48

0001 //===-- TCPSocket.h ---------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_HOST_COMMON_TCPSOCKET_H
0010 #define LLDB_HOST_COMMON_TCPSOCKET_H
0011 
0012 #include "lldb/Host/MainLoopBase.h"
0013 #include "lldb/Host/Socket.h"
0014 #include "lldb/Host/SocketAddress.h"
0015 #include <map>
0016 #include <string>
0017 #include <vector>
0018 
0019 namespace lldb_private {
0020 class TCPSocket : public Socket {
0021 public:
0022   explicit TCPSocket(bool should_close);
0023   TCPSocket(NativeSocket socket, bool should_close);
0024   ~TCPSocket() override;
0025 
0026   // returns port number or 0 if error
0027   uint16_t GetLocalPortNumber() const;
0028 
0029   // returns ip address string or empty string if error
0030   std::string GetLocalIPAddress() const;
0031 
0032   // must be connected
0033   // returns port number or 0 if error
0034   uint16_t GetRemotePortNumber() const;
0035 
0036   // must be connected
0037   // returns ip address string or empty string if error
0038   std::string GetRemoteIPAddress() const;
0039 
0040   int SetOptionNoDelay();
0041   int SetOptionReuseAddress();
0042 
0043   Status Connect(llvm::StringRef name) override;
0044   Status Listen(llvm::StringRef name, int backlog) override;
0045 
0046   using Socket::Accept;
0047   llvm::Expected<std::vector<MainLoopBase::ReadHandleUP>>
0048   Accept(MainLoopBase &loop,
0049          std::function<void(std::unique_ptr<Socket> socket)> sock_cb) override;
0050 
0051   Status CreateSocket(int domain);
0052 
0053   bool IsValid() const override;
0054 
0055   std::string GetRemoteConnectionURI() const override;
0056 
0057   std::vector<std::string> GetListeningConnectionURI() const override;
0058 
0059 private:
0060   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
0061 
0062   void CloseListenSockets();
0063 
0064   std::map<int, SocketAddress> m_listen_sockets;
0065 };
0066 }
0067 
0068 #endif // LLDB_HOST_COMMON_TCPSOCKET_H