Adding DOCUMENTATION flag to the CMakeLists.txt
[libt2n] / src / socket_server.hxx
index a72ae48..bbba379 100644 (file)
@@ -1,26 +1,30 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Gerd v. Egidy                                   *
- *   gve@intra2net.com                                                     *
- *                                                                         *
- *   This library is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Lesser General Public License version   *
- *   2.1 as published by the Free Software Foundation.                     *
- *                                                                         *
- *   This library is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU Lesser General Public License for more details.                   *
- *                                                                         *
- *   You should have received a copy of the GNU Lesser General Public      *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
+/*
+Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
+
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
 #ifndef __LIBT2N_SOCKET_SERVER
 #define __LIBT2N_SOCKET_SERVER
 
 #include <sys/types.h>
 #include <string>
+#include <set>
 
 #include "server.hxx"
 #include "socket_handler.hxx"
@@ -45,6 +49,9 @@ class socket_server : public socket_handler, public server
     private:
         fd_set connection_set;
         std::string unix_path;
+        std::set<int> sockets_set;
+
+        void start_listening();
 
         void new_connection();
 
@@ -52,10 +59,8 @@ class socket_server : public socket_handler, public server
         void remove_connection_socket(int sock);
 
     protected:
-        void log(log_level_values level, const std::string& message)
-            { log(level,message.c_str()); }
-        void log(log_level_values level, const char* message)
-            { server::log(level,message); }
+        std::ostream* get_logstream(log_level_values level)
+            { return server::get_logstream(level); }
 
     public:
         socket_server(int port, const std::string& ip="0.0.0.0");
@@ -63,7 +68,9 @@ class socket_server : public socket_handler, public server
 
         ~socket_server();
 
-        bool fill_buffer(long long usec_timeout=-1);
+        bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
+        std::set<int> get_sockets_set()
+            { return sockets_set; };
 };
 
 /** @brief Socket based connection
@@ -76,19 +83,21 @@ class socket_server_connection : public socket_handler, public server_connection
 
     private:
         socket_server_connection(int _sock, socket_type_value _stype, int _timeout)
-           : server_connection(_timeout), socket_handler(_sock,_stype)
+           : socket_handler(_sock,_stype), server_connection(_timeout)
            { }
 
-        void log(log_level_values level, const char* message);
+        ~socket_server_connection();
+
+        std::ostream* get_logstream(log_level_values level)
+            { return server_connection::get_logstream(level); }
 
         void real_write(const std::string& data)
             { socket_write(data); }
 
     public:
-        bool fill_buffer(long long usec_timeout=-1)
-            { return socket_handler::fill_buffer(buffer,usec_timeout); }
+        bool fill_buffer(long long usec_timeout=-1,long long* usec_timeout_remaining=NULL);
 
-        void close();
+        virtual void close();
 };
 
 }