00001 // 00002 // plumbing - C++ wrapper facades for Berkeley sockets 00003 // Copyright (C) 2009 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU General Public License, version 3, as published 00007 // by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT 00010 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00012 // more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along 00015 // with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #ifndef LIBPLUMBING_ENDPOINT_LISTENER_H 00019 #define LIBPLUMBING_ENDPOINT_LISTENER_H 00020 00021 #include <libplumbing/endpoint.h> 00022 00023 namespace plumbing { 00024 00025 class reactor; // forward 00026 00036 class endpoint_listener: 00037 public endpoint 00038 { 00039 public: 00043 virtual ~endpoint_listener(); 00044 00045 protected: 00059 endpoint_listener(reactor &svc, int port_number, int repeat_count); 00060 00074 endpoint_listener(reactor &svc, const std::string &port_number, 00075 int repeat_count); 00076 00077 protected: 00091 void process_read(); 00092 00093 // See base class for documentation. 00094 void process_write(); 00095 00105 void add_endpoint(const endpoint::pointer &ep); 00106 00113 virtual int get_default_port() const = 0; 00114 00129 virtual endpoint::pointer endpoint_factory(int fd, void *adr, 00130 int adrlen) = 0; 00131 00132 // See base class for documentation. 00133 int get_read_file_descriptor(); 00134 00135 private: 00141 reactor &svc; 00142 00152 int port_number; 00153 00159 int repeat_count; 00160 00166 void create_listening_socket(); 00167 00171 endpoint_listener(); 00172 00176 endpoint_listener(const endpoint_listener &); 00177 00181 endpoint_listener &operator=(const endpoint_listener &); 00182 }; 00183 00184 } 00185 00186 #endif // LIBPLUMBING_ENDPOINT_LISTENER_H 00187 // vim: set ts=8 sw=4 et