X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fplatform%2Fsockets%2Ftcp.h;h=15c2db7ed9c163a1f87debee923c8b8eb6724458;hb=d9de2aae6b2f47b8e1faacc69adba7406b9d85f0;hp=ffc372ccacfcad10e7cb90a7d4c7aff94bfc5849;hpb=996665192725398172263999b88c63663d11db04;p=deb_libcec.git diff --git a/src/lib/platform/sockets/tcp.h b/src/lib/platform/sockets/tcp.h index ffc372c..15c2db7 100644 --- a/src/lib/platform/sockets/tcp.h +++ b/src/lib/platform/sockets/tcp.h @@ -2,7 +2,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -40,7 +40,7 @@ namespace PLATFORM class CTcpSocket : public CCommonSocket { public: - CTcpSocket(const CStdString &strHostname, uint16_t iPort) : + CTcpSocket(const std::string &strHostname, uint16_t iPort) : CCommonSocket(INVALID_SOCKET_VALUE, strHostname), m_iPort(iPort) {} @@ -120,10 +120,52 @@ namespace PLATFORM uint16_t m_iPort; }; + class CTcpClientSocket : public CCommonSocket + { + public: + CTcpClientSocket(tcp_socket_t socket) : + CCommonSocket(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 { public: - CTcpConnection(const CStdString &strHostname, uint16_t iPort) : + CTcpConnection(const std::string &strHostname, uint16_t iPort) : CProtectedSocket (new CTcpSocket(strHostname, iPort)) {} virtual ~CTcpConnection(void) {} };