]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/TcpSocket_p.h
Stablized HTTP access on all platforms. (issue #54, issue #11)
[bamtools.git] / src / api / internal / io / TcpSocket_p.h
index 4cd1f1a0614b0623656c2537068b88d2063c5a68..2ad2dee13bdf09b1926667c13824be3127175668 100644 (file)
@@ -2,9 +2,9 @@
 // TcpSocket_p.h (c) 2011 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
+// Last modified: 7 December 2011 (DB)
 // ---------------------------------------------------------------------------
-// Provides TCP socket I/O
+// Provides basic TCP I/O interface
 // ***************************************************************************
 
 #ifndef TCPSOCKET_P_H
 namespace BamTools {
 namespace Internal {
 
+class BamHttp;
 class TcpSocketEngine;
 
 class TcpSocket {
 
     // enums
     public:
-        enum SocketError { UnknownSocketError     = -1
+        enum SocketError { NoError                = -2
+                         , UnknownSocketError     = -1
                          , ConnectionRefusedError = 0
                          , RemoteHostClosedError
                          , HostNotFoundError
@@ -72,7 +74,9 @@ class TcpSocket {
         bool CanReadLine(void) const;
         void ClearBuffer(void); // force buffer to clear (not a 'flush', just a 'discard')
         int64_t Read(char* data, const unsigned int numBytes);
-        std::string ReadLine(void);
+        std::string ReadLine(int64_t max = 0);
+        int64_t ReadLine(char* dest, size_t max);
+        bool WaitForReadLine(void);
         int64_t Write(const char* data, const unsigned int numBytes);
 
         // connection values
@@ -93,7 +97,7 @@ class TcpSocket {
                          const std::string& port,
                          IBamIODevice::OpenMode mode);
         bool InitializeSocketEngine(HostAddress::NetworkProtocol protocol);
-        bool ReadFromSocket(void);
+        int64_t ReadFromSocket(void);
         void ResetSocketEngine(void);
 
     // data members
@@ -114,6 +118,8 @@ class TcpSocket {
         TcpSocket::SocketError m_error;
         TcpSocket::SocketState m_state;
         std::string m_errorString;
+
+        friend class BamHttp;
 };
 
 } // namespace Internal