00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_SERVER_STREAM_SOCKET_H_
00028 #define CEYLAN_SERVER_STREAM_SOCKET_H_
00029
00030
00031
00032 #include "CeylanStreamSocket.h"
00033 #include "CeylanTypes.h"
00034 #include "CeylanSystem.h"
00035
00036 #include <string>
00037
00038
00039
00040
00041 namespace Ceylan
00042 {
00043
00044
00045
00046 namespace Network
00047 {
00048
00049
00050
00056 class AnonymousStreamSocket ;
00057
00058
00059
00079 class CEYLAN_DLL ServerStreamSocket : public StreamSocket
00080 {
00081
00082
00083
00085 typedef Ceylan::Uint32 ConnectionCount ;
00086
00087
00088
00089 public:
00090
00091
00092
00098 class CEYLAN_DLL ServerStreamSocketException:
00099 public StreamSocketException
00100 {
00101 public:
00102
00103 explicit ServerStreamSocketException(
00104 const std::string & reason ) ;
00105
00106 virtual ~ServerStreamSocketException() throw() ;
00107
00108 } ;
00109
00110
00111
00112
00128 explicit ServerStreamSocket( Port serverPort,
00129 bool reuse = true, bool blocking = false ) ;
00130
00131
00132
00134 virtual ~ServerStreamSocket() throw() ;
00135
00136
00137
00148 virtual void run() ;
00149
00150
00151
00164 virtual AnonymousStreamSocket * accept() = 0 ;
00165
00166
00167
00174 virtual Port getLocalPort() const ;
00175
00176
00177
00183 virtual ConnectionCount getMaximumPendingConnectionsCount()
00184 const ;
00185
00186
00187
00193 virtual void setMaximumPendingConnectionsCount(
00194 ConnectionCount newMax ) ;
00195
00196
00197
00203 static const Ceylan::Uint32
00204 DefaultMaximumPendingConnectionsCount = 20 ;
00205
00206
00207
00220 virtual const std::string toString(
00221 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00222
00223
00224
00225
00226 protected:
00227
00228
00229
00239 virtual void prepareToAccept() ;
00240
00241
00242
00251 virtual void cleanAfterAccept() ;
00252
00253
00254
00263 virtual bool closeAcceptedConnections() = 0 ;
00264
00265
00266
00304 virtual void accepted( AnonymousStreamSocket & newConnection ) ;
00305
00306
00307
00313 virtual bool isRequestedToStop() const ;
00314
00315
00316
00324 virtual void requestToStop() ;
00325
00326
00327
00328
00334 bool _bound ;
00335
00336
00337
00338
00339 private:
00340
00341
00342
00350 bool _stopRequested ;
00351
00352
00353
00361 Ceylan::Uint32 _maximumPendingConnectionsCount ;
00362
00363
00364
00373 ServerStreamSocket( const ServerStreamSocket & source ) ;
00374
00375
00376
00385 ServerStreamSocket & operator = (
00386 const ServerStreamSocket & source ) ;
00387
00388
00389
00390 } ;
00391
00392
00393 }
00394
00395 }
00396
00397
00398
00399
00400 #endif // CEYLAN_SERVER_STREAM_SOCKET_H_
00401