libt2n: (reinhard) socket handler: buffer and blcok sizes are configurable now; incom...
[libt2n] / src / socket_handler.hxx
index 82ccdad..b9aa175 100644 (file)
@@ -32,8 +32,8 @@ namespace libt2n
 class socket_handler
 {
     private:
-        static const unsigned int recv_buffer_size=2048;
-        static const unsigned int write_block_size=4096;
+        static const unsigned int default_recv_buffer_size=2048;
+        static const unsigned int default_write_block_size=4096;
 
         socket_type_value socket_type;
 
@@ -41,9 +41,10 @@ class socket_handler
 
     protected:
         int sock;
+        unsigned int recv_buffer_size;
+        unsigned int write_block_size;
 
-        socket_handler(int _sock, socket_type_value _socket_type)
-            { sock=_sock; socket_type=_socket_type; }
+        socket_handler(int _sock, socket_type_value _socket_type);
 
         void set_socket_options(int sock);
 
@@ -58,11 +59,17 @@ class socket_handler
         bool fill_buffer(std::string& buffer);
 
     public:
-        /// is this a tcp or udp socket connection
+        /// is this a tcp or unix socket connection
         socket_type_value get_type()
             { return socket_type; }
 
         bool is_closed();
+
+        void set_recv_buffer_size(unsigned int new_recv_buffer_size);
+        void set_write_block_size(unsigned int new_write_block_size);
+
+        unsigned int get_recv_buffer_size() const { return recv_buffer_size; }
+        unsigned int get_write_block_size() const { return write_block_size; }
 };
 
 }