JetByteTools::Socket::CStreamSocketConnectionManager Class Reference
[Stream SocketsConnection managers]

Inherits JetByteTools::Socket::CUsesMSWinSockExtensions, JetByteTools::Socket::IStreamSocketConnectionManager, and JetByteTools::Socket::IManageStreamSocketConnectionFilters.

Inherited by JetByteTools::Socket::CStreamSocketServer, and JetByteTools::Socket::CStreamSocketServerEx.

Inheritance diagram for JetByteTools::Socket::CStreamSocketConnectionManager:

Inheritance graph
[legend]
Collaboration diagram for JetByteTools::Socket::CStreamSocketConnectionManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

A connection manager for stream sockets.


Public Types

enum  ZeroByteReadConfiguration { NoZeroByteRead, ZeroByteAsyncRead, ZeroByteSyncRead }
 How we perform zero byte reads, if at all. More...

Public Member Functions

 CStreamSocketConnectionManager (IStreamSocketConnectionManagerCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &allocator, ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter)
 Construct a connection manager with the supplied callback interface, I pool, allocators and connection limiter.
virtual ~CStreamSocketConnectionManager ()
CSmartStreamSocket Connect (const IFullAddress &address, const void *pUserData=0)
 Connects, synchronously, to the specified address and returns a smart pointer to the resulting stream socket. Throws exceptions on failure to connect, the resulting stream socket is always connected and valid. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.
CSmartStreamSocket ConnectNoThrow (const IFullAddress &address, const void *pUserData=0) throw ()
 Connects, synchronously, to the specified address and returns a smart pointer to the resulting stream socket. Does not throw exceptions, the smart stream pointer will be null if the connection attempt fails; call CSmartStreamSocket::Get() to determine this. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), before returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.
CSmartStreamSocket AsyncConnect (const IFullAddress &address, const void *pUserData=0)
 Connects, asynchronously, to the specified address and returns a smart pointer to the resulting stream socket. Throws exceptions on some failures to connect. The smart stream pointer is not connected until the IStreamSocketConnectionManagerCallback::OnConnectionEstablished() has been called and this may be before or after the function returns to the caller. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), either before or after returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), either before or after returning, if the connection is successful.
bool AsyncConnectAvailable (const IAddressType &addressType) const
 Returns true if the platform supports asynchronous connections.
void AbortAllConnections ()
 Aborts all connections that are managed by this connection manager.
void AddConnectionFilter (IFilterStreamSocketConnections &filter)
 (wire -> A -> B -> user).
void InitiateShutdown ()
 Starts the shutdown process and returns immediately.
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.

Protected Member Functions

CSmartStreamSocket Connect (const IFullAddress &address, const void *pUserData, const void *pFilterData)
CSmartStreamSocket ConnectNoThrow (const IFullAddress &address, const void *pUserData, const void *pFilterData) throw ()
CSmartStreamSocket AsyncConnect (const IFullAddress &address, const void *pUserData, const void *pFilterData)
void ConnectionEstablished (IStreamSocketEx &socket, const IAddress &address)
void AssociateDevice (SOCKET s, JetByteTools::IO::IHandler &handler) const
DWORD GetPoolThreadsTlsIndex () const
size_t GetPoolThreadsIdentifier () const
void PostIoOperation (JetByteTools::IO::IHandler &handler, JetByteTools::IO::IBuffer &buffer, DWORD operation)
virtual void HandleOperation (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer, DWORD dwIoSize, DWORD lastError)
 Handles an I/O operation.
virtual void ReleaseSocket (IPoolableSocket &socket)
 Used to pass the socket back to the allocator when its reference count reaches 0.
virtual void RequestRead (IStreamSocketEx &socket, JetByteTools::IO::IBuffer *pBuffer)
virtual void RequestWrite (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer)
virtual void ExecuteWrite (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer) const
 Called by a socket to have the manager actually perform a write operation. The socket controls this action as it may be responsible for sequencing buffers into the correct order before issuing the writes.
virtual JetByteTools::IO::IBufferAllocateBuffer ()
 Allows the socket to access the buffer allocator that is being used by the manager so that it can generate write calls using the correct buffers. These write calls are the result of the non buffer based Write() and TryWrite() methods being called.
CSmartStreamSocketEx AllocateSocket (SOCKET theSocket)
SOCKET CreateSocket (const IAddressType &addressType) 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.

Protected Attributes

ILimitConnectionsm_connectionLimiter

Friends

class TLoggingStreamSocketConnectionManager


Member Enumeration Documentation

enum JetByteTools::Socket::CStreamSocketConnectionManager::ZeroByteReadConfiguration

How we perform zero byte reads, if at all.

Enumerator:
NoZeroByteRead 
ZeroByteAsyncRead 
ZeroByteSyncRead 


Constructor & Destructor Documentation

JetByteTools::Socket::CStreamSocketConnectionManager::CStreamSocketConnectionManager ( IStreamSocketConnectionManagerCallback callback,
JetByteTools::IO::IIOPool pool,
IAllocateStreamSockets socketAllocator,
JetByteTools::IO::IAllocateBuffers allocator,
ZeroByteReadConfiguration  zeroByteReadConfiguration = NoZeroByteRead,
ILimitConnections connectionLimiter = CConnectionLimiter::NoLimitLimiter 
)

Construct a connection manager with the supplied callback interface, I pool, allocators and connection limiter.

JetByteTools::Socket::CStreamSocketConnectionManager::~CStreamSocketConnectionManager (  )  [virtual]


Member Function Documentation

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::Connect ( const IFullAddress address,
const void *  pUserData = 0 
)

Connects, synchronously, to the specified address and returns a smart pointer to the resulting stream socket. Throws exceptions on failure to connect, the resulting stream socket is always connected and valid. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::ConnectNoThrow ( const IFullAddress address,
const void *  pUserData = 0 
) throw ()

Connects, synchronously, to the specified address and returns a smart pointer to the resulting stream socket. Does not throw exceptions, the smart stream pointer will be null if the connection attempt fails; call CSmartStreamSocket::Get() to determine this. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), before returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::AsyncConnect ( const IFullAddress address,
const void *  pUserData = 0 
)

Connects, asynchronously, to the specified address and returns a smart pointer to the resulting stream socket. Throws exceptions on some failures to connect. The smart stream pointer is not connected until the IStreamSocketConnectionManagerCallback::OnConnectionEstablished() has been called and this may be before or after the function returns to the caller. Passes the user data pointer through to IStreamSocketConnectionManagerCallback::OnPreOutgoingConnect() before returning. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), either before or after returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), either before or after returning, if the connection is successful.

bool JetByteTools::Socket::CStreamSocketConnectionManager::AsyncConnectAvailable ( const IAddressType addressType  )  const

Returns true if the platform supports asynchronous connections.

void JetByteTools::Socket::CStreamSocketConnectionManager::AbortAllConnections (  ) 

Aborts all connections that are managed by this connection manager.

void JetByteTools::Socket::CStreamSocketConnectionManager::AddConnectionFilter ( IFilterStreamSocketConnections filter  ) 

(wire -> A -> B -> user).

void JetByteTools::Socket::CStreamSocketConnectionManager::InitiateShutdown (  ) 

Starts the shutdown process and returns immediately.

Reimplemented in JetByteTools::Socket::CStreamSocketServer, and JetByteTools::Socket::CStreamSocketServerEx.

void JetByteTools::Socket::CStreamSocketConnectionManager::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.

Reimplemented in JetByteTools::Socket::CStreamSocketServer, and JetByteTools::Socket::CStreamSocketServerEx.

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::Connect ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData 
) [protected]

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::ConnectNoThrow ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData 
) throw () [protected]

CSmartStreamSocket JetByteTools::Socket::CStreamSocketConnectionManager::AsyncConnect ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData 
) [protected]

void JetByteTools::Socket::CStreamSocketConnectionManager::ConnectionEstablished ( IStreamSocketEx socket,
const IAddress address 
) [protected]

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

DWORD JetByteTools::Socket::CStreamSocketConnectionManager::GetPoolThreadsTlsIndex (  )  const [protected]

size_t JetByteTools::Socket::CStreamSocketConnectionManager::GetPoolThreadsIdentifier (  )  const [protected]

void JetByteTools::Socket::CStreamSocketConnectionManager::PostIoOperation ( JetByteTools::IO::IHandler handler,
JetByteTools::IO::IBuffer buffer,
DWORD  operation 
) [protected]

void JetByteTools::Socket::CStreamSocketConnectionManager::HandleOperation ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer buffer,
DWORD  dwIoSize,
DWORD  lastError 
) [protected, virtual]

Handles an I/O operation.

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

void JetByteTools::Socket::CStreamSocketConnectionManager::ReleaseSocket ( IPoolableSocket socket  )  [protected, virtual]

Used to pass the socket back to the allocator when its reference count reaches 0.

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

Reimplemented in JetByteTools::Socket::CStreamSocketServer, and JetByteTools::Socket::CStreamSocketServerEx.

void JetByteTools::Socket::CStreamSocketConnectionManager::RequestRead ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer pBuffer 
) [protected, virtual]

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

void JetByteTools::Socket::CStreamSocketConnectionManager::RequestWrite ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer buffer 
) [protected, virtual]

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

void JetByteTools::Socket::CStreamSocketConnectionManager::ExecuteWrite ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer buffer 
) const [protected, virtual]

Called by a socket to have the manager actually perform a write operation. The socket controls this action as it may be responsible for sequencing buffers into the correct order before issuing the writes.

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

IBuffer * JetByteTools::Socket::CStreamSocketConnectionManager::AllocateBuffer (  )  [protected, virtual]

Allows the socket to access the buffer allocator that is being used by the manager so that it can generate write calls using the correct buffers. These write calls are the result of the non buffer based Write() and TryWrite() methods being called.

Implements JetByteTools::Socket::IStreamSocketConnectionManager.

CSmartStreamSocketEx JetByteTools::Socket::CStreamSocketConnectionManager::AllocateSocket ( SOCKET  theSocket  )  [protected]

SOCKET JetByteTools::Socket::CStreamSocketConnectionManager::CreateSocket ( const IAddressType addressType  )  const [protected]

bool JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadConnectEx ( SOCKET  s  )  const [inherited]

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

bool JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadAcceptEx ( SOCKET  s  )  const [inherited]

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

void JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadGetAcceptExSockaddrs ( SOCKET  s  )  const [inherited]

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

bool JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadDisconnectEx ( SOCKET  s  )  const [inherited]

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

bool JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadTransmitFile ( SOCKET  s  )  const [inherited]

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

bool JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::CanDisconnectSocketForReuse ( SOCKET  s  )  const [inherited]

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

int JetByteTools::Socket::CUsesMSWinSockExtensions::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 JetByteTools::Socket::CUsesMSWinSockExtensions::LoadWSARecvMsg ( SOCKET  s  )  const [inherited]

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


Friends And Related Function Documentation

friend class TLoggingStreamSocketConnectionManager [friend]


Member Data Documentation

ILimitConnections& JetByteTools::Socket::CStreamSocketConnectionManager::m_connectionLimiter [protected]


Generated on Tue May 8 17:48:08 2007 for JetByte Socket Tools by  doxygen 1.5.2