libt2n: (gerd) add protocol version config, add server callbacks (not fully working...
[libt2n] / src / socket_client.hxx
index 198e1a7..a35bbfd 100644 (file)
 
 namespace libt2n
 {
+/** @brief a connection from client to server using sockets.
 
+    Use this class to connect from a client to a server.
+ */
 class socket_client_connection : public client_connection, public socket_handler
 {
-    static const int max_retries_default=3;
+    public:
+        static const int max_retries_default=3;
 
     private:
         void real_write(const std::string& data)
@@ -41,12 +45,22 @@ class socket_client_connection : public client_connection, public socket_handler
         std::string server;
         int port;
 
+        std::ostream* get_logstream(log_level_values level)
+            { return client_connection::get_logstream(level); }
+
     public:
         socket_client_connection(const std::string& _server, int _port, int _max_retries=max_retries_default);
         socket_client_connection(const std::string& _path, int _max_retries=max_retries_default);
 
-        void fill_buffer(long long usec_timeout=-1)
-            { socket_handler::fill_buffer(buffer,usec_timeout); }
+        /** @brief read data from the socket and copy it into buffer
+            @param usec_timeout wait until new data is found, max timeout usecs.
+                    -1: wait endless
+                    NULL: no timeout
+            @retval true if new data was found (does not mean that the received data 
+                    is a complete packet though)
+        */
+        bool fill_buffer(long long usec_timeout=-1)
+            { return socket_handler::fill_buffer(buffer,usec_timeout); }
 
         void close();
 };