/*************************************************************************** * 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. * ***************************************************************************/ #ifndef __LIBT2N_SOCKET_SERVER #define __LIBT2N_SOCKET_SERVER #include #include "server.hxx" namespace libt2n { /** Socket based server class */ class socket_server : public server { public: enum socket_type_value { tcp_s, unix_s }; private: int sock; fd_set connection_set; socket_type_value socket_type; std::string unix_path; void set_socket_options(int sock); void new_connection(); public: socket_server(int port, const char* ip="0.0.0.0"); socket_server(const char* path, mode_t filemode, const char* user="", const char* group=""); ~socket_server(); socket_type_value get_type() { return socket_type; } void fill_buffer(long long usec_timeout=-1); }; /** Socket based connection class */ class socket_connection : public connection { friend class socket_server; private: int sock; socket_connection(int _sock, int _timeout); public: void close(); void fill_buffer(void); void write(const std::string& data); }; } #endif