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 () |
TStreamSocketServer & | operator= (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 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... |
enum Status [inherited] |
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] |
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] |
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] |
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] |