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

TConnectionManagerBase Class Template Reference

Inheritance diagram for TConnectionManagerBase:
Collaboration diagram for TConnectionManagerBase:

List of all members.

template<class Base1, class Base2, class Manager, class Callback, class SocketAllocator>
class JetByteTools::Socket::TConnectionManagerBase< Base1, Base2, Manager, Callback, SocketAllocator >


Public Member Functions

 TConnectionManagerBase (const TConnectionManagerBase &rhs)
 ~TConnectionManagerBase ()
TConnectionManagerBaseoperator= (const TConnectionManagerBase &rhs)
DWORD AbortAllConnections ()
 Aborts all active sockets that are managed by the supplied manager and returns the number of active sockets that were aborted.
virtual void BeginShutdown ()
 Starts the shutdown process and returns immediately.
virtual void WaitForShutdownToComplete ()
 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.
virtual bool WaitForShutdownToComplete (Milliseconds timeout)
 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.
virtual void ForceShutdown ()
 Force a shutdown to occur, this is DANGEROUS to use as it can result in a shutdown of this object, and its potential destruction, whilst there are sockets alive that may call back into this object. Use with care!

Protected Member Functions

 TConnectionManagerBase (Callback &callback, JetByteTools::IO::IIOPool &pool, Manager &manager, SocketAllocator &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator, ILimitConnections &connectionLimiter)
bool ShutdownIsInProgress () const
virtual void Start ()
void EnsureCanConnectNow ()
bool CheckCanConnectNow ()
void AssociateDevice (SOCKET s, JetByteTools::IO::IHandler &handler) const
DWORD AbortAllConnections (ConnectionClosureReason reason)
JetByteTools::IO::CSmartBuffer AllocateBuffer () override
JetByteTools::IO::CSmartBuffer AllocateCustomSizedBuffer (JetByteTools::IO::IBuffer::BufferSize bufferSize) override
JetByteTools::IO::CSmartBuffer AllocateBuffer (JetByteTools::IO::IPoolBuffers &pool) override
void IncrementActiveConnections ()
void DecrementActiveConnections ()
virtual void ReleaseSocket (IPoolableSocket &socket, bool wasUserSocket) override
virtual void ShutdownComplete ()
void SetBufferSize (SOCKET s, SocketBufferSize bufferSize, int optionName) const
bool ConnectEx (SOCKET s, const struct sockaddr FAR *name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength, LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped) const
 Loads, if necessary and available, and then calls ConnectEx(). If the function isn't available then an exception is thrown.
bool LoadConnectEx (SOCKET s) const
 Attempts to load ConnectEx() via a call to WSAIoctl(). Returns true if successful.
bool AcceptEx (SOCKET listenSocket, SOCKET acceptSocket, PVOID pOutputBuffer, DWORD receiveDataLength, DWORD localAddressLength, DWORD remoteAddressLength, LPDWORD bytesReceived, LPOVERLAPPED pOverlapped) const
 Loads, if necessary and available, and then calls AcceptEx(). If the function isn't available then an exception is thrown.
bool LoadAcceptEx (SOCKET s) const
 Attempts to load AcceptEx() via a call to WSAIoctl(). Returns true if successful.
void GetAcceptExSockaddrs (PVOID pOutputBuffer, DWORD receiveDataLength, DWORD localAddressLength, DWORD remoteAddressLength, LPSOCKADDR *pLocalSockaddr, LPINT pLocalSockaddrLength, LPSOCKADDR *pRemoteSockaddr, LPINT pRemoteSockaddrLength) const
 Loads, if necessary and available, and then calls GetAcceptExSockaddrs(). If the function isn't available then an exception is thrown.
bool LoadGetAcceptExSockaddrs (SOCKET s) const
 Attempts to load GetAcceptExSockaddrs() via a call to WSAIoctl(). Returns true if successful.
bool DisconnectEx (SOCKET s, LPOVERLAPPED pOverlapped, DWORD flags) const
 Loads, if necessary and available, and then calls DisconnectEx(). If the function isn't available then an exception is thrown.
bool LoadDisconnectEx (SOCKET s) const
 Attempts to load DisconnectEx() via a call to WSAIoctl(). Returns true if successful.
bool TransmitFile (SOCKET s, HANDLE fileToTransmit, DWORD numberOfBytesToWrite, DWORD numberOfBytesPerSend, LPOVERLAPPED lOverlapped, LPTRANSMIT_FILE_BUFFERS lTransmitBuffers, DWORD flags) const
 Loads, if necessary and available, and then calls TransmitFile(). If the function isn't available then an exception is thrown.
bool LoadTransmitFile (SOCKET s) const
 Attempts to load TransmitFile() via a call to WSAIoctl(). Returns true if successful.
bool DisconnectSocketForReuse (SOCKET s) const
 Attempts to disconnect a socket for reuse first by attempting to call DisconnectEx() and then by attempting to call TransmitFile() in 'disconnect for reuse mode' see http://msdn2.microsoft.com/en-us/library/ms740565.aspx for details. If neither option is available then an exception is thrown.
bool CanDisconnectSocketForReuse (SOCKET s) const
 Returns true if either DisconnectEx() or TransmitFile() can be a call to WSAIoctl().
int WSARecvMsg (SOCKET s, LPWSAMSG lpMsg, LPDWORD lpdwNumberOfBytesRecvd, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) const
 Loads, if necessary and available, and then calls WSARecvMsg(). If the function isn't available then an exception is thrown.
bool LoadWSARecvMsg (SOCKET s) const
 Attempts to load WSARecvMsg() via a call to WSAIoctl(). Returns true if successful.
void EnableDispatchOnThisThread (bool enable)

Static Protected Member Functions

static bool ShouldDispatchOnThisThread ()
static bool ShouldDispatchForThisSocket (const void *pSocket)
static const void * EnableDispatchForThisSocket (const void *pSocket)
static void DisableDispatchForThisSocket (const void *pSocket)

Protected Attributes

JetByteTools::IO::IIOPoolm_pool
SocketAllocator & m_socketAllocator
ILimitConnectionsm_connectionLimiter
JetByteTools::Core::CManualResetEvent m_noActiveConnectionsEvent
JetByteTools::Core::CAtomicCounter m_activeConnections
const bool m_canEnableSkipCompletionPortOnSuccess

Constructor & Destructor Documentation

TConnectionManagerBase ( const TConnectionManagerBase< Base1, Base2, Manager, Callback, SocketAllocator > &  rhs  ) 

~TConnectionManagerBase (  )  [inline]

TConnectionManagerBase ( Callback &  callback,
JetByteTools::IO::IIOPool pool,
Manager &  manager,
SocketAllocator &  socketAllocator,
JetByteTools::IO::IAllocateBuffers bufferAllocator,
ILimitConnections connectionLimiter 
) [inline, protected]


Member Function Documentation

TConnectionManagerBase& operator= ( const TConnectionManagerBase< Base1, Base2, Manager, Callback, SocketAllocator > &  rhs  ) 

DWORD AbortAllConnections (  )  [inline]

Aborts all active sockets that are managed by the supplied manager and returns the number of active sockets that were aborted.

void BeginShutdown (  )  [inline, virtual]

void WaitForShutdownToComplete (  )  [inline, 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.

Reimplemented in TDatagramSocketServer, and TStreamSocketServerEx< TStreamSocketConnectionManager< CFilteringStreamSocketConnectionManagerBase > >.

bool WaitForShutdownToComplete ( Milliseconds  timeout  )  [inline, 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.

Reimplemented in TDatagramSocketServer, and TStreamSocketServerEx< TStreamSocketConnectionManager< CFilteringStreamSocketConnectionManagerBase > >.

void ForceShutdown (  )  [inline, virtual]

Force a shutdown to occur, this is DANGEROUS to use as it can result in a shutdown of this object, and its potential destruction, whilst there are sockets alive that may call back into this object. Use with care!

Reimplemented in TDatagramSocketServer, and TStreamSocketServerEx< TStreamSocketConnectionManager< CFilteringStreamSocketConnectionManagerBase > >.

bool ShutdownIsInProgress (  )  const [inline, protected]

void EnsureCanConnectNow (  )  [inline, protected]

bool CheckCanConnectNow (  )  [inline, protected]

void AssociateDevice ( SOCKET  s,
JetByteTools::IO::IHandler handler 
) const [inline, protected]

DWORD AbortAllConnections ( ConnectionClosureReason  reason  )  [inline, protected]

JetByteTools::IO::CSmartBuffer AllocateBuffer (  )  [inline, override, protected]

JetByteTools::IO::CSmartBuffer AllocateCustomSizedBuffer ( JetByteTools::IO::IBuffer::BufferSize  bufferSize  )  [inline, override, protected]

JetByteTools::IO::CSmartBuffer AllocateBuffer ( JetByteTools::IO::IPoolBuffers pool  )  [inline, override, protected]

void IncrementActiveConnections (  )  [inline, protected]

void DecrementActiveConnections (  )  [inline, protected]

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

void ShutdownComplete (  )  [inline, protected, virtual]

void SetBufferSize ( SOCKET  s,
SocketBufferSize  bufferSize,
int  optionName 
) const [inline, protected]

bool ConnectEx ( SOCKET  s,
const struct sockaddr FAR *  name,
int  namelen,
PVOID  lpSendBuffer,
DWORD  dwSendDataLength,
LPDWORD  lpdwBytesSent,
LPOVERLAPPED  lpOverlapped 
) const [inherited]

Loads, if necessary and available, and then calls ConnectEx(). If the function isn't available then an exception is thrown.

bool LoadConnectEx ( SOCKET  s  )  const [inherited]

Attempts to load ConnectEx() via a call to WSAIoctl(). Returns true if successful.

bool AcceptEx ( SOCKET  listenSocket,
SOCKET  acceptSocket,
PVOID  pOutputBuffer,
DWORD  receiveDataLength,
DWORD  localAddressLength,
DWORD  remoteAddressLength,
LPDWORD  bytesReceived,
LPOVERLAPPED  pOverlapped 
) const [inherited]

Loads, if necessary and available, and then calls AcceptEx(). If the function isn't available then an exception is thrown.

bool LoadAcceptEx ( SOCKET  s  )  const [inherited]

Attempts to load AcceptEx() via a call to WSAIoctl(). Returns true if successful.

void GetAcceptExSockaddrs ( PVOID  pOutputBuffer,
DWORD  receiveDataLength,
DWORD  localAddressLength,
DWORD  remoteAddressLength,
LPSOCKADDR *  pLocalSockaddr,
LPINT  pLocalSockaddrLength,
LPSOCKADDR *  pRemoteSockaddr,
LPINT  pRemoteSockaddrLength 
) const [inherited]

Loads, if necessary and available, and then calls GetAcceptExSockaddrs(). If the function isn't available then an exception is thrown.

bool LoadGetAcceptExSockaddrs ( SOCKET  s  )  const [inherited]

Attempts to load GetAcceptExSockaddrs() via a call to WSAIoctl(). Returns true if successful.

bool DisconnectEx ( SOCKET  s,
LPOVERLAPPED  pOverlapped,
DWORD  flags 
) const [inherited]

Loads, if necessary and available, and then calls DisconnectEx(). If the function isn't available then an exception is thrown.

bool LoadDisconnectEx ( SOCKET  s  )  const [inherited]

Attempts to load DisconnectEx() via a call to WSAIoctl(). Returns true if successful.

bool TransmitFile ( SOCKET  s,
HANDLE  fileToTransmit,
DWORD  numberOfBytesToWrite,
DWORD  numberOfBytesPerSend,
LPOVERLAPPED  lOverlapped,
LPTRANSMIT_FILE_BUFFERS  lTransmitBuffers,
DWORD  flags 
) const [inherited]

Loads, if necessary and available, and then calls TransmitFile(). If the function isn't available then an exception is thrown.

bool LoadTransmitFile ( SOCKET  s  )  const [inherited]

Attempts to load TransmitFile() via a call to WSAIoctl(). Returns true if successful.

bool DisconnectSocketForReuse ( SOCKET  s  )  const [inherited]

Attempts to disconnect a socket for reuse first by attempting to call DisconnectEx() and then by attempting to call TransmitFile() in 'disconnect for reuse mode' see http://msdn2.microsoft.com/en-us/library/ms740565.aspx for details. If neither option is available then an exception is thrown.

bool CanDisconnectSocketForReuse ( SOCKET  s  )  const [inherited]

Returns true if either DisconnectEx() or TransmitFile() can be a call to WSAIoctl().

int WSARecvMsg ( SOCKET  s,
LPWSAMSG  lpMsg,
LPDWORD  lpdwNumberOfBytesRecvd,
LPWSAOVERLAPPED  lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
) const [inherited]

Loads, if necessary and available, and then calls WSARecvMsg(). If the function isn't available then an exception is thrown.

bool LoadWSARecvMsg ( SOCKET  s  )  const [inherited]

Attempts to load WSARecvMsg() via a call to WSAIoctl(). Returns true if successful.

bool ShouldDispatchOnThisThread (  )  [static, inherited]

bool ShouldDispatchForThisSocket ( const void *  pSocket  )  [static, inherited]

void EnableDispatchOnThisThread ( bool  enable  )  [inherited]

const void * EnableDispatchForThisSocket ( const void *  pSocket  )  [static, inherited]

void DisableDispatchForThisSocket ( const void *  pSocket  )  [static, inherited]


Member Data Documentation

SocketAllocator& m_socketAllocator [protected]


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