CStreamSocketConnectionManager Class Reference
[Stream SocketsConnection managers]

Inheritance diagram for CStreamSocketConnectionManager:

Inheritance graph
[legend]
Collaboration diagram for 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...
enum  { DefaultTCPBufferSize = 0 }
typedef unsigned int TCPBufferSize

Public Member Functions

 CStreamSocketConnectionManager (IStreamSocketConnectionManagerCallback &callback, JetByteTools::IO::IIOPool &pool, IAllocateStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &allocator, const ZeroByteReadConfiguration zeroByteReadConfiguration=NoZeroByteRead, ILimitConnections &connectionLimiter=CConnectionLimiter::NoLimitLimiter)
 Construct a connection manager with the supplied callback interface, I/O pool, allocators and connection limiter.
virtual ~CStreamSocketConnectionManager ()
virtual
CSmartStreamSocket 
Connect (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)
virtual
CSmartStreamSocket 
ConnectNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize) throw ()
virtual
CSmartStreamSocket 
AsyncConnect (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)
virtual
CSmartStreamSocket 
AsyncConnectNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize) throw ()
virtual
CSmartStreamSocket 
ConnectAsyncIfAvailable (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)
virtual
CSmartStreamSocket 
ConnectAsyncIfAvailableNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize) throw ()
virtual bool AsyncConnectAvailable (const IAddressType &addressType) const
 Returns true if the platform supports asynchronous connections for this address type.
virtual void AbortAllConnections ()
 Aborts all connections that are managed by this connection manager.
virtual void AddConnectionFilter (IFilterStreamSocketConnections &filter)
 Adds a connection filter to the connection manager. Connection filters are called in order to process calls with requests being called from "top to bottom" and completions being called from "bottom to top". For example, if filter A is added and then filter B is added and then we make a write request the data would be processed first by filter B and then by filter A (user -> B -> A -> wire). When a read completes.
void InitiateShutdown ()
 Starts the shutdown process and returns immediately.
bool WaitForShutdownToComplete (const Milliseconds timeout=INFINITE)
 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 or the timeout has expired. Returns true if the shutdown is complete.
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!
virtual
CSmartStreamSocket 
Connect (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. Calls IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.
virtual
CSmartStreamSocket 
ConnectNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), before returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.
virtual
CSmartStreamSocket 
AsyncConnect (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. 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.
virtual
CSmartStreamSocket 
AsyncConnectNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=0 throw ()
 Connects, asynchronously, 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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. 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.
virtual
CSmartStreamSocket 
ConnectAsyncIfAvailable (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=0
 If the platform supports asynchronous connections for this address type then acts as an AsyncConnect() else acts as a ConnectNoThrow().
virtual
CSmartStreamSocket 
ConnectAsyncIfAvailableNoThrow (const IFullAddress &address, const void *pUserData=0, const TCPBufferSize recvBufferSize=DefaultTCPBufferSize, const TCPBufferSize sendBufferSize=DefaultTCPBufferSize)=0 throw ()
 If the platform supports asynchronous connections for this address type then acts as an AsyncConnectNoThrow() else acts as a ConnectNoThrow().

Protected Member Functions

CSmartStreamSocket Connect (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize)
CSmartStreamSocket ConnectNoThrow (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize) throw ()
CSmartStreamSocket AsyncConnect (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize)
CSmartStreamSocket AsyncConnectNoThrow (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize) throw ()
CSmartStreamSocket ConnectAsyncIfAvailable (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize)
CSmartStreamSocket ConnectAsyncIfAvailableNoThrow (const IFullAddress &address, const void *pUserData, const void *pFilterData, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize) throw ()
void ConnectionEstablished (IStreamSocketEx &socket, const IAddress &address)
void ConnectionFailed (IStreamSocketEx &socket, const IAddress &address, const DWORD lastError)
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, const JetByteTools::IO::IBuffer::Operation operation, const bool forceDispatchToPool=true)
virtual void HandleOperation (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer, const DWORD ioSize, const 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)
 Called by a socket to have the manager shedule a read operation to occur on one of the I/O threads.
virtual void RequestWrite (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer)
 Called by a socket to have the manager shedule a write operation to occur on one of the I/O threads.
virtual void ExecuteWrite (IStreamSocketEx &socket, JetByteTools::IO::IBuffer &buffer)
 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::IBuffer
AllocateBuffer ()
 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.
virtual void OnClientClose (IStreamSocketEx &socket)
 Called by the socket when a OnConnectionClientClose event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.
virtual void OnConnectionReset (IStreamSocketEx &socket, const DWORD lastError)
 Called by the socket when a OnConnectionConnectionReset event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.
virtual void OnConnectionClosed (IStreamSocketEx &socket)
 Called by the socket when a OnConnectionClosed event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.
CSmartStreamSocketEx AllocateSocket (SOCKET theSocket)
SOCKET CreateSocket (const IAddressType &addressType, const TCPBufferSize recvBufferSize, const TCPBufferSize sendBufferSize) const
void SetBufferSize (SOCKET s, const TCPBufferSize bufferSize, const 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.

Protected Attributes

ILimitConnectionsm_connectionLimiter
JetByteTools::Win32::CWaitableCounter m_activeConnections

Member Typedef Documentation

typedef unsigned int TCPBufferSize [inherited]


Member Enumeration Documentation

enum ZeroByteReadConfiguration

How we perform zero byte reads, if at all.

Enumerator:
NoZeroByteRead 
ZeroByteAsyncRead 
ZeroByteSyncRead 

anonymous enum [inherited]

Enumerator:
DefaultTCPBufferSize 


Constructor & Destructor Documentation

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

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

~CStreamSocketConnectionManager (  )  [virtual]

Reimplemented in CStreamSocketConnectionManager, and CStreamSocketConnectionManager.


Member Function Documentation

CSmartStreamSocket Connect ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [virtual]

CSmartStreamSocket ConnectNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [virtual]

CSmartStreamSocket AsyncConnect ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [virtual]

CSmartStreamSocket AsyncConnectNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [virtual]

CSmartStreamSocket ConnectAsyncIfAvailable ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [virtual]

CSmartStreamSocket ConnectAsyncIfAvailableNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [virtual]

bool AsyncConnectAvailable ( const IAddressType addressType  )  const [virtual]

Returns true if the platform supports asynchronous connections for this address type.

Implements ICreateStreamSocketConnections.

void AbortAllConnections (  )  [virtual]

Aborts all connections that are managed by this connection manager.

Implements ICreateStreamSocketConnections.

void AddConnectionFilter ( IFilterStreamSocketConnections filter  )  [virtual]

Adds a connection filter to the connection manager. Connection filters are called in order to process calls with requests being called from "top to bottom" and completions being called from "bottom to top". For example, if filter A is added and then filter B is added and then we make a write request the data would be processed first by filter B and then by filter A (user -> B -> A -> wire). When a read completes.

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

Implements IAcceptStreamSocketConnectionFilters.

void InitiateShutdown (  ) 

Starts the shutdown process and returns immediately.

Reimplemented in CStreamSocketServer, and CStreamSocketServerEx.

bool WaitForShutdownToComplete ( const Milliseconds  timeout = INFINITE  ) 

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 or the timeout has expired. Returns true if the shutdown is complete.

Reimplemented in CStreamSocketServer, and CStreamSocketServerEx.

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!

Reimplemented in CStreamSocketServer, and CStreamSocketServerEx.

CSmartStreamSocket Connect ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) [protected]

CSmartStreamSocket ConnectNoThrow ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) throw () [protected]

CSmartStreamSocket AsyncConnect ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) [protected]

CSmartStreamSocket AsyncConnectNoThrow ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) throw () [protected]

CSmartStreamSocket ConnectAsyncIfAvailable ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) [protected]

CSmartStreamSocket ConnectAsyncIfAvailableNoThrow ( const IFullAddress address,
const void *  pUserData,
const void *  pFilterData,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) throw () [protected]

void ConnectionEstablished ( IStreamSocketEx socket,
const IAddress address 
) [protected]

void ConnectionFailed ( IStreamSocketEx socket,
const IAddress address,
const DWORD  lastError 
) [protected]

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

DWORD GetPoolThreadsTlsIndex (  )  const [protected]

size_t GetPoolThreadsIdentifier (  )  const [protected]

void PostIoOperation ( JetByteTools::IO::IHandler handler,
JetByteTools::IO::IBuffer buffer,
const JetByteTools::IO::IBuffer::Operation  operation,
const bool  forceDispatchToPool = true 
) [protected]

void HandleOperation ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer buffer,
const DWORD  ioSize,
const DWORD  lastError 
) [protected, virtual]

Handles an I/O operation.

Implements IStreamSocketConnectionManager.

void ReleaseSocket ( IPoolableSocket socket  )  [protected, virtual]

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

Implements IStreamSocketConnectionManager.

Reimplemented in CStreamSocketServer, and CStreamSocketServerEx.

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

Called by a socket to have the manager shedule a read operation to occur on one of the I/O threads.

Implements IStreamSocketConnectionManager.

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

Called by a socket to have the manager shedule a write operation to occur on one of the I/O threads.

Implements IStreamSocketConnectionManager.

void ExecuteWrite ( IStreamSocketEx socket,
JetByteTools::IO::IBuffer buffer 
) [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 IStreamSocketConnectionManager.

IBuffer * 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 IStreamSocketConnectionManager.

void OnClientClose ( IStreamSocketEx socket  )  [protected, virtual]

Called by the socket when a OnConnectionClientClose event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.

Implements IStreamSocketConnectionManager.

void OnConnectionReset ( IStreamSocketEx socket,
const DWORD  lastError 
) [protected, virtual]

Called by the socket when a OnConnectionConnectionReset event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.

Implements IStreamSocketConnectionManager.

void OnConnectionClosed ( IStreamSocketEx socket  )  [protected, virtual]

Called by the socket when a OnConnectionClosed event is detected. Allows the manager to dispatch the event to the thread pool so that it occurs when the socket is not holding its internal lock.

Implements IStreamSocketConnectionManager.

CSmartStreamSocketEx AllocateSocket ( SOCKET  theSocket  )  [protected]

SOCKET CreateSocket ( const IAddressType addressType,
const TCPBufferSize  recvBufferSize,
const TCPBufferSize  sendBufferSize 
) const [protected]

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

virtual CSmartStreamSocket Connect ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [pure virtual, inherited]

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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. Calls IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.

virtual CSmartStreamSocket ConnectNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [pure virtual, inherited]

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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. Calls IStreamSocketConnectionManagerCallback::OnOutgoingConnectionFailed(), before returning, if the connection fails and IStreamSocketConnectionManagerCallback::OnConnectionEstablished(), before returning, if the connection is successful.

virtual CSmartStreamSocket AsyncConnect ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [pure virtual, inherited]

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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. 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.

virtual CSmartStreamSocket AsyncConnectNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [pure virtual, inherited]

Connects, asynchronously, 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. Sets send and recv buffer sizes before connection if values other than 0 are supplied; note that this WILL affect the TCP window size. 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.

virtual CSmartStreamSocket ConnectAsyncIfAvailable ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) [pure virtual, inherited]

If the platform supports asynchronous connections for this address type then acts as an AsyncConnect() else acts as a ConnectNoThrow().

virtual CSmartStreamSocket ConnectAsyncIfAvailableNoThrow ( const IFullAddress address,
const void *  pUserData = 0,
const TCPBufferSize  recvBufferSize = DefaultTCPBufferSize,
const TCPBufferSize  sendBufferSize = DefaultTCPBufferSize 
) throw () [pure virtual, inherited]

If the platform supports asynchronous connections for this address type then acts as an AsyncConnectNoThrow() else acts as a ConnectNoThrow().

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.


Member Data Documentation

ILimitConnections& m_connectionLimiter [protected]

JetByteTools::Win32::CWaitableCounter m_activeConnections [protected]


Generated on Mon Sep 7 14:09:46 2009 for JetByte Socket Tools - v6.1 by  doxygen 1.5.3