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

TStreamSocketServer Class Template Reference
[Stream SocketsSocket servers]

Inheritance diagram for TStreamSocketServer:
Collaboration diagram for TStreamSocketServer:

List of all members.


Detailed Description

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

A socket server for stream sockets. Runs a thread to handle connection establishment using accept.

Public Types

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

Public Member Functions

 TStreamSocketServer (IStreamSocketServerCallback &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.
 TStreamSocketServer (IStreamSocketServerCallback &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.
 TStreamSocketServer (const IFullAddress &address, ListenBacklog listenBacklog, IStreamSocketServerCallback &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.
 TStreamSocketServer (const IFullAddress &address, ListenBacklog listenBacklog, IStreamSocketServerCallback &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.
 TStreamSocketServer (const TStreamSocketServer &rhs)
virtual ~TStreamSocketServer ()
TStreamSocketServeroperator= (const TStreamSocketServer &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 SetThreadName (const JetByteTools::Core::_tstring &threadName)
 Sets the name of the accept thread as displayed in the Visual Studio debugger to the supplied name. By default the constructor sets the name of the thread to "SocketServer". Note that this must be called before calling Start() for it to have an effect.
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)

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

TStreamSocketServer ( IStreamSocketServerCallback 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.

TStreamSocketServer ( IStreamSocketServerCallback 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.

TStreamSocketServer ( const IFullAddress address,
ListenBacklog  listenBacklog,
IStreamSocketServerCallback 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.

TStreamSocketServer ( const IFullAddress address,
ListenBacklog  listenBacklog,
IStreamSocketServerCallback 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.

TStreamSocketServer ( const TStreamSocketServer< Base > &  rhs  ) 

~TStreamSocketServer (  )  [inline, virtual]


Member Function Documentation

TStreamSocketServer& operator= ( const TStreamSocketServer< 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 SetThreadName ( const JetByteTools::Core::_tstring threadName  )  [inline]

Sets the name of the accept thread as displayed in the Visual Studio debugger to the supplied name. By default the constructor sets the name of the thread to "SocketServer". Note that this must be called before calling Start() for it to have an effect.

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]


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