/*************************************************************************** * 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 { class socket_server : public server { public: enum socket_type { tcp, unix }; private: int socket; fd_set connection_set; socket_type type; string unix_path; public: socket_server(int port, const char* ip="0.0.0.0"); socket_server(const char* path, mode_t chmod, const char* user="", const char* group=""); ~socket_server(); socket_type get_type() { return type; } void fill_buffer(long long usec_timeout=-1); }; class socket_connection : public connection { private: int socket; friend void socket_server::fill_buffer(long long usec_timeout); socket_connection(int _socket, int _timeout); public: void close(); void fill_buffer(void); void write(const std::string& data); }; } #endif