00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the Ceylan library. 00005 * 00006 * The Ceylan library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The Ceylan library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and the GNU General Public License along with the Ceylan library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #ifndef CEYLAN_SEQUENTIAL_SERVER_STREAM_SOCKET_H_ 00028 #define CEYLAN_SEQUENTIAL_SERVER_STREAM_SOCKET_H_ 00029 00030 00031 #include "CeylanServerStreamSocket.h" // for inheritance 00032 #include "CeylanSystem.h" // for FileDescriptor 00033 00034 #include <string> 00035 00036 00037 00038 00039 namespace Ceylan 00040 { 00041 00042 00043 namespace Network 00044 { 00045 00046 00047 00054 class AnonymousStreamSocket ; 00055 00056 00057 00096 class CEYLAN_DLL SequentialServerStreamSocket: public ServerStreamSocket 00097 { 00098 00099 00100 00101 public: 00102 00103 00104 00110 class SequentialServerStreamSocketException : 00111 public ServerStreamSocketException 00112 { 00113 00114 public: 00115 00116 explicit SequentialServerStreamSocketException( 00117 const std::string & reason ) ; 00118 00119 virtual ~SequentialServerStreamSocketException() 00120 throw() ; 00121 00122 } ; 00123 00124 00125 00126 00138 explicit SequentialServerStreamSocket( Port listeningPort, 00139 bool reuse = true ) ; 00140 00141 00142 00144 virtual ~SequentialServerStreamSocket() throw() ; 00145 00146 00147 00153 virtual bool isConnected() const ; 00154 00155 00156 00169 virtual AnonymousStreamSocket * accept() ; 00170 00171 00172 00189 virtual System::FileDescriptor getFileDescriptorForTransport() 00190 const ; 00191 00192 00193 00206 virtual const std::string toString( 00207 Ceylan::VerbosityLevels level = Ceylan::high ) const ; 00208 00209 00210 00211 00212 protected: 00213 00214 00223 virtual bool closeAcceptedConnections() ; 00224 00225 00226 00227 00228 private: 00229 00230 00240 AnonymousStreamSocket * _currentConnection ; 00241 00242 00243 00252 SequentialServerStreamSocket( 00253 const SequentialServerStreamSocket & source ) ; 00254 00255 00264 SequentialServerStreamSocket & operator = ( 00265 const SequentialServerStreamSocket & source ) ; 00266 00267 00268 00269 } ; 00270 00271 } 00272 00273 } 00274 00275 00276 00277 #endif // CEYLAN_SEQUENTIAL_SERVER_STREAM_SOCKET_H_ 00278