The C++ framework for developing highly scalable, high performance servers on Windows platforms.

TStreamSocketServerEx Class Template Reference
[Stream SocketsSocket servers]

Inheritance diagram for TStreamSocketServerEx:
Collaboration diagram for TStreamSocketServerEx:

List of all members.


Detailed Description

template<class Base>
class JetByteTools::Socket::TStreamSocketServerEx< Base >

A socket serer for stream sockets. Uses AcceptEx to handle connection establishment, does not run a thread for connection establishment. Can not handle 'accept and read' connection establishment.

Public Types

enum  Status {
  NotStarted, AcceptingConnections, Paused, ShuttingDown,
  Stopped, Indeterminate
}

Public Member Functions

 TStreamSocketServerEx (IStreamSocketServerExCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator, ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter, OutOfBandDataReadConfiguration outOfBandDataReadConfiguration=NoOutOfBandData)
 Construct a socket server with the supplied callback interface, I/O pool, allocators and connection limiter.
 TStreamSocketServerEx (IStreamSocketServerExCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator, SocketBufferSize recvBufferSize=DefaultSocketBufferSize, SocketBufferSize sendBufferSize=DefaultSocketBufferSize, ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter, OutOfBandDataReadConfiguration outOfBandDataReadConfiguration=NoOutOfBandData)
 Construct a socket server with the supplied callback interface, I/O pool, allocators, TCP buffer sizes and connection limiter.
 TStreamSocketServerEx (const IFullAddress &address, ListenBacklog listenBacklog, IStreamSocketServerExCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator, ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter, OutOfBandDataReadConfiguration outOfBandDataReadConfiguration=NoOutOfBandData)
 Construct a socket server with the supplied callback interface, I/O pool, allocators and connection limiter. Listen on the supplied address for connections with the specified listen backlog.
 TStreamSocketServerEx (const IFullAddress &address, ListenBacklog listenBacklog, IStreamSocketServerExCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator, SocketBufferSize recvBufferSize, SocketBufferSize sendBufferSize=DefaultSocketBufferSize, ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter, OutOfBandDataReadConfiguration outOfBandDataReadConfiguration=NoOutOfBandData)
 Construct a socket server with the supplied callback interface, I/O pool, allocators, TCP buffer sizes and connection limiter. Listen on the supplied address for connections with the specified listen backlog.
 TStreamSocketServerEx (const TStreamSocketServerEx &rhs)
virtual ~TStreamSocketServerEx ()
TStreamSocketServerExoperator= (const TStreamSocketServerEx &rhs)
void SetAddressDetails (const IFullAddress &address, ListenBacklog listenBacklog, SocketBufferSize recvBufferSize=DefaultSocketBufferSize, SocketBufferSize sendBufferSize=DefaultSocketBufferSize)
 Set the address to listen for connections on and the size of the listen backlog queue and the send and recv buffer sizes.
void SetListeningParameters (ListenBacklog listenBacklog, ListenBacklog numPendingAccepts, bool closeListenSocketOnMaxConnections)
void Start () override
void StartAcceptingConnections () override
void StopAcceptingConnections () override
void BeginShutdown () override
 Starts the shutdown process and returns immediately.
void WaitForShutdownToComplete () override
 Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed.
bool WaitForShutdownToComplete (Milliseconds timeout) override
 Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't.
void ForceShutdown () override
 If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!).
Status GetStatus () const override
 Returns the status of the server.

Static Public Member Functions

static
JetByteTools::Core::_tstring 
GetStatusAsString (Status status)

Static Public Attributes

static const
ListenBacklog 
SoMaxNumPendingAccepts = 200

Protected Member Functions

const IFullAddressGetAddress () const
void ReleaseSocket (IPoolableSocket &socket, bool wasUserSocket) override
virtual SOCKET CreateListeningSocket (SOCKET socket, const IAddress &address, ListenBacklog listenBacklog)
 Called to convert the supplied socket to a socket which is listening on the supplied address with the specified "listen backlog" (if supported). Override if the standard behaviour doesn't work for your socket type...

Member Enumeration Documentation

enum Status [inherited]

Enumerator:
NotStarted 
AcceptingConnections 
Paused 
ShuttingDown 
Stopped 
Indeterminate 


Constructor & Destructor Documentation

TStreamSocketServerEx ( IStreamSocketServerExCallback callback,
JetByteTools::IO::IIOPool pool,
IAllocateStreamSockets socketAllocator,
JetByteTools::IO::IAllocateBuffers bufferAllocator,
ZeroByteReadConfiguration  zeroByteReadConfiguration = NoZeroByteRead,
ILimitConnections connectionLimiter = CConnectionLimiter::NoLimitLimiter,
OutOfBandDataReadConfiguration  outOfBandDataReadConfiguration = NoOutOfBandData 
) [inline]

Construct a socket server with the supplied callback interface, I/O pool, allocators and connection limiter.

TStreamSocketServerEx ( IStreamSocketServerExCallback callback,
JetByteTools::IO::IIOPool pool,
IAllocateStreamSockets socketAllocator,
JetByteTools::IO::IAllocateBuffers bufferAllocator,
SocketBufferSize  recvBufferSize = DefaultSocketBufferSize,
SocketBufferSize  sendBufferSize = DefaultSocketBufferSize,
ZeroByteReadConfiguration  zeroByteReadConfiguration = NoZeroByteRead,
ILimitConnections connectionLimiter = CConnectionLimiter::NoLimitLimiter,
OutOfBandDataReadConfiguration  outOfBandDataReadConfiguration = NoOutOfBandData 
) [inline]

Construct a socket server with the supplied callback interface, I/O pool, allocators, TCP buffer sizes and connection limiter.

TStreamSocketServerEx ( const IFullAddress address,
ListenBacklog  listenBacklog,
IStreamSocketServerExCallback callback,
JetByteTools::IO::IIOPool pool,
IAllocateStreamSockets socketAllocator,
JetByteTools::IO::IAllocateBuffers bufferAllocator,
ZeroByteReadConfiguration  zeroByteReadConfiguration = NoZeroByteRead,
ILimitConnections connectionLimiter = CConnectionLimiter::NoLimitLimiter,
OutOfBandDataReadConfiguration  outOfBandDataReadConfiguration = NoOutOfBandData 
) [inline]

Construct a socket server with the supplied callback interface, I/O pool, allocators and connection limiter. Listen on the supplied address for connections with the specified listen backlog.

TStreamSocketServerEx ( const IFullAddress address,
ListenBacklog  listenBacklog,
IStreamSocketServerExCallback callback,
JetByteTools::IO::IIOPool pool,
IAllocateStreamSockets socketAllocator,
JetByteTools::IO::IAllocateBuffers bufferAllocator,
SocketBufferSize  recvBufferSize,
SocketBufferSize  sendBufferSize = DefaultSocketBufferSize,
ZeroByteReadConfiguration  zeroByteReadConfiguration = NoZeroByteRead,
ILimitConnections connectionLimiter = CConnectionLimiter::NoLimitLimiter,
OutOfBandDataReadConfiguration  outOfBandDataReadConfiguration = NoOutOfBandData 
) [inline]

Construct a socket server with the supplied callback interface, I/O pool, allocators, TCP buffer sizes and connection limiter. Listen on the supplied address for connections with the specified listen backlog.

~TStreamSocketServerEx (  )  [inline, virtual]


Member Function Documentation

TStreamSocketServerEx& operator= ( const TStreamSocketServerEx< Base > &  rhs  ) 

void SetAddressDetails ( const IFullAddress address,
ListenBacklog  listenBacklog,
SocketBufferSize  recvBufferSize = DefaultSocketBufferSize,
SocketBufferSize  sendBufferSize = DefaultSocketBufferSize 
) [inline]

Set the address to listen for connections on and the size of the listen backlog queue and the send and recv buffer sizes.

void SetListeningParameters ( ListenBacklog  listenBacklog,
ListenBacklog  numPendingAccepts,
bool  closeListenSocketOnMaxConnections 
) [inline]

void Start (  )  [inline, override, virtual]

Implements IServerControl.

void StartAcceptingConnections (  )  [inline, override, virtual]

Implements IServerControl.

void StopAcceptingConnections (  )  [inline, override, virtual]

Implements IServerControl.

void BeginShutdown (  )  [inline, override, virtual]

Starts the shutdown process and returns immediately.

Implements IServerControl.

void WaitForShutdownToComplete (  )  [inline, override, virtual]

Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed.

Implements IServerControl.

bool WaitForShutdownToComplete ( Milliseconds  timeout  )  [inline, override, virtual]

Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't.

Implements IServerControl.

void ForceShutdown (  )  [inline, override, virtual]

If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!).

Implements IServerControl.

IServerControl::Status GetStatus (  )  const [inline, override, virtual]

Returns the status of the server.

Implements IServerControl.

const IFullAddress & GetAddress (  )  const [inline, protected]

void ReleaseSocket ( IPoolableSocket socket,
bool  wasUserSocket 
) [inline, override, protected]

SOCKET CreateListeningSocket ( SOCKET  socket,
const IAddress address,
ListenBacklog  listenBacklog 
) [inline, protected, virtual]

Called to convert the supplied socket to a socket which is listening on the supplied address with the specified "listen backlog" (if supported). Override if the standard behaviour doesn't work for your socket type...

_tstring GetStatusAsString ( Status  status  )  [static, inherited]


Member Data Documentation

const ListenBacklog SoMaxNumPendingAccepts = 200 [inline, static]


Generated on Sun Sep 12 19:10:42 2021 for The Server Framework - v7.4 by doxygen 1.5.3