LibCecSharp: fixed - set the primary LA in CecLogicalAddresses
[deb_libcec.git] / src / lib / platform / sockets / tcp.h
index ffc372ccacfcad10e7cb90a7d4c7aff94bfc5849..1dad499e5ea608947f576b25e39739dc1c3aa37e 100644 (file)
@@ -40,7 +40,7 @@ namespace PLATFORM
   class CTcpSocket : public CCommonSocket<tcp_socket_t>
   {
     public:
-      CTcpSocket(const CStdString &strHostname, uint16_t iPort) :
+      CTcpSocket(const std::string &strHostname, uint16_t iPort) :
         CCommonSocket<tcp_socket_t>(INVALID_SOCKET_VALUE, strHostname),
         m_iPort(iPort) {}
 
@@ -120,10 +120,52 @@ namespace PLATFORM
       uint16_t   m_iPort;
   };
 
+  class CTcpClientSocket : public CCommonSocket<tcp_socket_t>
+  {
+  public:
+    CTcpClientSocket(tcp_socket_t socket) :
+      CCommonSocket<tcp_socket_t>(socket, "tcpclient") {}
+
+    virtual ~CTcpClientSocket(void) {}
+
+    virtual bool Open(uint64_t iTimeoutMs = 0)
+    {
+      (void) iTimeoutMs;
+      return true;
+    }
+
+    virtual void Close(void)
+    {
+      TcpSocketClose(m_socket);
+      m_socket = INVALID_SOCKET_VALUE;
+    }
+
+    virtual void Shutdown(void)
+    {
+      TcpSocketShutdown(m_socket);
+      m_socket = INVALID_SOCKET_VALUE;
+    }
+
+    virtual ssize_t Write(void* data, size_t len)
+    {
+      return TcpSocketWrite(m_socket, &m_iError, data, len);
+    }
+
+    virtual ssize_t Read(void* data, size_t len, uint64_t iTimeoutMs = 0)
+    {
+      return TcpSocketRead(m_socket, &m_iError, data, len, iTimeoutMs);
+    }
+
+    virtual bool IsOpen(void)
+    {
+      return m_socket != INVALID_SOCKET_VALUE;
+    }
+  };
+
   class CTcpConnection : public CProtectedSocket<CTcpSocket>
   {
   public:
-    CTcpConnection(const CStdString &strHostname, uint16_t iPort) :
+    CTcpConnection(const std::string &strHostname, uint16_t iPort) :
       CProtectedSocket<CTcpSocket> (new CTcpSocket(strHostname, iPort)) {}
     virtual ~CTcpConnection(void) {}
   };