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

CHTTPSocketServer Class Reference

Inheritance diagram for CHTTPSocketServer:
Collaboration diagram for CHTTPSocketServer:

List of all members.

Public Types

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

Public Member Functions

 CHTTPSocketServer (IManageResources &resourceManager, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::BufferCount maxBuffers, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::PendingWriteCount maxPendingWrites, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::Percentage notificationPercentageStepSize, JetByteTools::Socket::SocketBufferSize recvBufferSize, JetByteTools::Socket::SocketBufferSize sendBufferSize, const JetByteTools::Socket::IFullAddress &address, JetByteTools::Socket::ListenBacklog listenBacklog, JetByteTools::IO::IIOPool &pool, JetByteTools::Socket::IAllocateSequencedStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator)
 CHTTPSocketServer (JetByteTools::Socket::IMonitorStreamSocketFlowControl &monitor, IManageResources &resourceManager, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::BufferCount maxBuffers, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::PendingWriteCount maxPendingWrites, JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter::Percentage notificationPercentageStepSize, JetByteTools::Socket::SocketBufferSize recvBufferSize, JetByteTools::Socket::SocketBufferSize sendBufferSize, const JetByteTools::Socket::IFullAddress &address, JetByteTools::Socket::ListenBacklog listenBacklog, JetByteTools::IO::IIOPool &pool, JetByteTools::Socket::IAllocateSequencedStreamSockets &socketAllocator, JetByteTools::IO::IAllocateBuffers &bufferAllocator)
 CHTTPSocketServer (const CHTTPSocketServer &rhs)
 ~CHTTPSocketServer ()
CHTTPSocketServeroperator= (const CHTTPSocketServer &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

void OnConnectionEstablished (JetByteTools::Socket::IStreamSocket &socket, const JetByteTools::Socket::IAddress &address) override
 Called when a connection is established. The address is the address that the socket is connected to. This is where you are expected to issue your first Read() or Write() call on a connection, if you don't and don't increase the reference count of the socket in some other way then the socket will close automatically.
void OnSocketReleased (JetByteTools::Core::IIndexedOpaqueUserData &userData) override
 Called when a connection is released back to the allocator. This is guarenteed to be the last event that happens on an active socket. The socket is dead at this point and you're passed the userData that was related to it so that you can perform some final cleanup if required. Note that you should not assume that you can use the address of the user data object for anything. Due to how the socket object's inheritance works this particular interface is different to the instance of IIndexedOpaqueUserData that you can cast to from the IStreamSocket interface that you're given in all of the other callbacks and the address of this user data will be different to the address of the user data passed in OnPreOutgoingConnect() for the same socket. Note that you can, of course, access the socket's user data store via the interface, you just can't use the address of the interface for anything useful.
void OnReadCompleted (JetByteTools::Socket::IStreamSocket &socket, JetByteTools::IO::CSmartBuffer &buffer) override
 Called when an asynchronous read completes. This is where you are given the data that has been received on the connection and where your business logic would usually be expected to start dealing with the data. You are generally expected to issue another Read() before this call completes, if you don't and don't increase the reference count of the socket in some other way then the socket will close automatically.
void OnConnectionClientClose (JetByteTools::Socket::IStreamSocket &socket) override
 Called when the 'read side' of the connection is closed by the remote end. The remote end of the connection can no longer send data to you as it has issued a shutdown() call and shut down at least the write side of its socket. This means that you can no longer read from the connection but you may still be able to write to the connection.
bool OnListFull (JetByteTools::Socket::IStreamSocket &socket, const JetByteTools::Socket::IMonitorStreamSocketFlowControl::ConnectionId id, JetByteTools::Socket::IMonitorStreamSocketFlowControl &monitor, const JetByteTools::IO::IBuffer &newBuffer, JetByteTools::IO::IBufferChain &buffers, JetByteTools::IO::IBufferChain &discardedBuffers) override
void OnListStatus (JetByteTools::Socket::IStreamSocket &socket, const DWORD percentageUsed) override
void OnListEmpty (JetByteTools::Socket::IStreamSocket &socket) override
const IFullAddress & GetAddress () 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

CHTTPSocketServer ( const CHTTPSocketServer rhs  ) 


Member Function Documentation

CHTTPSocketServer& operator= ( const CHTTPSocketServer rhs  ) 

void OnConnectionEstablished ( JetByteTools::Socket::IStreamSocket socket,
const JetByteTools::Socket::IAddress address 
) [override, protected, virtual]

Called when a connection is established. The address is the address that the socket is connected to. This is where you are expected to issue your first Read() or Write() call on a connection, if you don't and don't increase the reference count of the socket in some other way then the socket will close automatically.

Reimplemented from CStreamSocketServerExCallback.

void OnSocketReleased ( JetByteTools::Core::IIndexedOpaqueUserData userData  )  [override, protected, virtual]

Called when a connection is released back to the allocator. This is guarenteed to be the last event that happens on an active socket. The socket is dead at this point and you're passed the userData that was related to it so that you can perform some final cleanup if required. Note that you should not assume that you can use the address of the user data object for anything. Due to how the socket object's inheritance works this particular interface is different to the instance of IIndexedOpaqueUserData that you can cast to from the IStreamSocket interface that you're given in all of the other callbacks and the address of this user data will be different to the address of the user data passed in OnPreOutgoingConnect() for the same socket. Note that you can, of course, access the socket's user data store via the interface, you just can't use the address of the interface for anything useful.

Reimplemented from CStreamSocketServerExCallback.

void OnReadCompleted ( JetByteTools::Socket::IStreamSocket socket,
JetByteTools::IO::CSmartBuffer buffer 
) [override, protected, virtual]

Called when an asynchronous read completes. This is where you are given the data that has been received on the connection and where your business logic would usually be expected to start dealing with the data. You are generally expected to issue another Read() before this call completes, if you don't and don't increase the reference count of the socket in some other way then the socket will close automatically.

Reimplemented from CStreamSocketServerExCallback.

void OnConnectionClientClose ( JetByteTools::Socket::IStreamSocket socket  )  [override, protected, virtual]

Called when the 'read side' of the connection is closed by the remote end. The remote end of the connection can no longer send data to you as it has issued a shutdown() call and shut down at least the write side of its socket. This means that you can no longer read from the connection but you may still be able to write to the connection.

Reimplemented from CStreamSocketServerExCallback.

bool OnListFull ( JetByteTools::Socket::IStreamSocket socket,
const JetByteTools::Socket::IMonitorStreamSocketFlowControl::ConnectionId  id,
JetByteTools::Socket::IMonitorStreamSocketFlowControl monitor,
const JetByteTools::IO::IBuffer &  newBuffer,
JetByteTools::IO::IBufferChain buffers,
JetByteTools::IO::IBufferChain discardedBuffers 
) [override, protected, virtual]

void OnListStatus ( JetByteTools::Socket::IStreamSocket socket,
const DWORD  percentageUsed 
) [override, protected, virtual]

void OnListEmpty ( JetByteTools::Socket::IStreamSocket socket  )  [override, protected, virtual]

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

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, inherited]

void Start (  )  [inline, override, virtual, inherited]

Implements IServerControl.

void StartAcceptingConnections (  )  [inline, override, virtual, inherited]

Implements IServerControl.

void StopAcceptingConnections (  )  [inline, override, virtual, inherited]

Implements IServerControl.

void BeginShutdown (  )  [inline, override, virtual, inherited]

Starts the shutdown process and returns immediately.

Implements IServerControl.

void WaitForShutdownToComplete (  )  [inline, override, virtual, inherited]

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, inherited]

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, inherited]

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, inherited]

Returns the status of the server.

Implements IServerControl.

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

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

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

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, inherited]


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