Latest release of licensed socket server code: 6.2
The latest release of The Server Framework is now available. This release includes the following changes.
The following changes were made to the libraries.
Admin Library - 6.2
-
We now support Visual Studio 2010. At present the code has only been tested with the beta and release candidate versions.
-
New build configuration options. All of these are enabled by defining the option to 1 in
Config.hand disabled by defining them to 0; the default state if you do not do anything inConfig.his shown for each option: -
JETBYTE_TINY_XML_2_5_3- enabled by default. From this release TinyXML version 2.5.3 is available and is used by default in XMLTools. If you would prefer to continue to use TinyXML 2.5.2 then defineJETBYTE_TINY_XML_2_5_3to 0 in your Config.h -
You can enable the
FILE_SKIP_SET_EVENT_ON_HANDLEflag of SetFileCompletionNotificationModes() for stream sockets, datagram sockets,JetByteTools::IO::CAsyncFileWriterorJetByteTools::IO::CAsyncFileReaderusing the following configuration options: -
JETBYTE_PERF_STREAM_SOCKETS_SKIP_EVENT_ON_HANDLE- enabled by default. -
JETBYTE_PERF_DATAGRAM_SOCKETS_SKIP_EVENT_ON_HANDLE- enabled by default. -
JETBYTE_PERF_FILE_WRITER_SKIP_EVENT_ON_HANDLE- enabled by default. -
JETBYTE_PERF_FILE_READER_SKIP_EVENT_ON_HANDLE- enabled by default.
This potentially provides a very small performance improvement. You can turn off this functionality by defining the appropriate configuration option to 0 in your Config.h. See here for more details.
-
You can enable the
FILE_SKIP_COMPLETION_PORT_ON_SUCCESSflag of SetFileCompletionNotificationModes() for stream sockets, datagram sockets,JetByteTools::IO::CAsyncFileWriterorJetByteTools::IO::CAsyncFileReader. using the following configuration options: -
JETBYTE_PERF_STREAM_SOCKETS_SKIP_COMPLETION_PORT_ON_SUCCESS- enabled by default. -
JETBYTE_PERF_DATAGRAM_SOCKETS_SKIP_COMPLETION_PORT_ON_SUCCESS- DISABLED by default. -
JETBYTE_PERF_FILE_WRITER_SKIP_COMPLETION_PORT_ON_SUCCESS- DISABLED by default. -
JETBYTE_PERF_FILE_READER_SKIP_COMPLETION_PORT_ON_SUCCESS- enabled by default.
This provides a small performance improvement in situations where overlapped I/O operations complete straight away as the completion is handled on the thread that initiated the I/O operation rather than being marshalled to an I/O thread. You can turn off this functionality by defining the appropriate configuration option to 0 in your Config.h.
Note that this option is only enabled by default for stream sockets. You can, of course, enable the option by defining the appropriate configuration option to 1 in your Config.h BUT there is a known bug with enabling this option for UDP sockets on Windows Vista and Windows 7 which may cause resource leaks and we have been unable to exercise the new code for the JetByteTools::IO::CAsyncFileWriter during testing and so have not enabled the code at this time. See here for more details.
-
JETBYTE_DEBUG_BREAK_ON_CONNECTIONS_ACTIVE_DURING_DESTRUCTION- enabled by default. If enabled a breakpoint is triggered if you are in the debugger and there are connections active when a connection manager is destroyed. The connection manager base class cannot wait for these connections to complete as the callback that it uses to notify your code that connections have completed will likely have been destroyed by the time this code is executed. You should always have waited for a shutdown to complete and not created any connections again after that point before destroying your connection manager. You CAN and SHOULD wait for shutdown in your own derived class’s destructor! Enabling this option helps you spot situations where you are NOT waiting correctly in your own code. -
JETBYTE_DUMP_SOCKET_READ_AND_WRITE_DATA_TO_DEBUG_LOG- disabled by default. When enabled the low level socket I/O code dumps complete details of all data sent and received to the default debug trace log. This can be useful when developing connection filters. Note that this should not be left enabled as the debug generation is time consuming. -
JETBYTE_DISABLE_VS2005_DEBUG_UUIDLIB_CHECK- has been removed. It was too difficult to detect installations that needed it and you can fix the problem that it tried to work around with the hotfix that we link to from here. -
We now create typedefs for
DWORDandBYTEin Types.h. This means that we don’t need to include <wtypes.h> quite so often.
Win32 Tools Library - 6.2
-
Added
JetByteTools::Win32::CAtomicBool- a simple boolean class which provides an atomic way to query and toggle the value usingInterlockedCompareExchange() -
Fixed a memory leak bug in
JetByteTools::Win32::CCallStackwhere we were deleting an array withdeleterather thandelete []. -
Added
JetByteTools::Win32::CConditionalSmartPointer- a smart pointer which can be told, during construction or assignment, not to act as a smart pointer. This can be useful if sometimes you own some memory and sometimes you don’t and you want to hold the memory in a smart pointer when you DO own it… -
Breaking Change All instances of
InitiateShutdown()have been changed toBeginShutdown()this is to remove the issue with the Win32InitiateShutdown()function which is conditionally defined as eitherInitiateShutdownA()orInitiateShutdownW()and which could then cause issues. The following classes are affected: -
JetByteTools::Win32::CDirectoryChangeMonitor -
JetByteTools::Win32::ICollectableThreadPool -
JetByteTools::Win32::CIOCPWorkerThread -
JetByteTools::Win32::CThreadedCallbackTimerQueue -
JetByteTools::Win32::CThreadPool -
JetByteTools::Win32::CThreadPoolCollection -
Added
JetByteTools::Win32::ICompressDataan interface that represents a stateless data compressor/decompressor. At present the only implementation of this isJetByteTools::ZLib::CDataCompressor. -
JetByteTools::Win32::ISingleWriterMultipleReaderLock::Readernow takes aconst ISingleWriterMultipleReaderLockreference in its constructor as entering to read is a logicallyconstoperation for most classes that would be using theISingleWriterMultipleReaderLocklock. -
Added
JetByteTools::Win32::IWaitable::IsSignalled()which callsWait()with a timeout of zero to determine if the object is currently signalled. This gets around the need to cast the zero toJetByteTools::Millisecondsto avoid ambiguity. -
Fixed
JetByteTools::Win32::CNamedIndex::FindOrAdd()so that it only checks to see if the index collection is locked if it needs to add a new index. -
Added an optional null pointer dereference check to
JetByteTools::Win32::TReferenceCountedSmartPointer::operator->(). IfJETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCEis enabled then we throw an exception if the reference is null at point of use. -
Added
JetByteTools::Win32::CRegistryConfigurationan implementation ofJetByteTools::Win32::IConfigurationwhich reads data from a specify set of registry keys. -
Added
JetByteTools::Win32::CSmartBool::operator bool(). -
Added a new overload to
JetByteTools::Win32::CStringConverter::AtoBSTR(). -
Added some new conversion formats to
JetByteTools::Win32::CSystemTime. You can now pass date/times in any of the following string formats to theJetByteTools::Win32::CSystemTimeconstructor. -
YYYYMMDD HHMMSS -
YYYYMMDD HHMMSSMMM -
YYYY-MM-DD HH:MM:SS -
YYYY-MM-DD HH:MM:SS.MMM -
Added
JetByteTools::Win32::CSystemTime::GetAsHHMMSSMMM(). -
Added
JetByteTools::Win32::CSystemTime::GetAsDatabaseDateTimeStamp()which returns the date/time asYYYY-MM-DD HH:MM:SS.MMM -
Added
JetByteTools::Win32::CSystemTime::ContainsDate()which returnstrueif the date portion of date/time is valid. -
Breaking Change
JetByteTools::Win32::CTempDirectory::RemoveContents()now removes the contents of sub-directories as well as files within the temporary directory. -
Breaking Change
JetByteTools::Win32::CThread::WasStarted()has been removed and replaced byJetByteTools::Win32::CThread::IsRunning(). This is because instances ofJetByteTools::Win32::CThreadcan now be restarted after they have been shutdown. -
Fixed a rare memory leak with
JetByteTools::Win32::CThreadedCallbackTimerQueue. We now useJetByteTools::Win32::CConditionalSmartPointerto hold the timer queue so that failed construction of theJetByteTools::Win32::CThreadedCallbackTimerQueueafter the timer queue has been created causes the timer queue to be destroyed correctly. -
Added conditional code for VS2002 and VS2003 for
JetByteTools::Win32::GetStringLengthAsDWORD()and all other versions so that we are using the templated version for VS2005 and later and only using custom code for those compilers that don’t support the template code. This is to make it easier to move away from the custom code when we drop support for the older compilers. -
JetByteTools::Win32::CWaitableCounter::Increment()now returnstrueif the value was incremented from zero. -
JetByteTools::Win32::CWaitableCounter::Decrement()now returnstrueif the value was decremented to zero. -
Added
JetByteTools::Win32::CWaitableCounter::Add()which allows you to add an arbitrary amount to a waitable counter and correctly toggles the various events if the counter passes through zero. -
Added
JetByteTools::Win32::CWaitableCounter::Subtract()which allows you to subtract an arbitrary amount from a waitable counter and correctly toggles the various events if the counter passes through zero. -
Added
JetByteTools::Win32::CWaitableCounter::Incrementer::LeaveIncremented(). -
Added
JetByteTools::Win32::CWaitableCounter::Decrementer::LeaveDecremented(). -
JetByteTools::Win32::CExceptionnow strips trailing new lines from error messages obtained byJetByteTools::Win32::GetLastErrorMessage(). -
Added
JetByteTools::Win32::CSEHException::GetCallStack()which returns the callstack that was active when theJetByteTools::Win32::CSEHExceptionwas generated.
I/O Tools Library - 6.2
-
We now check for numeric overflow when we’re calculating the total size of the buffers in
JetByteTools::IO::CMultiBufferHandle::GetUsed(). -
Fixed a bug in
JetByteTools::IO::CAsyncFileWriter::HandleWriteRequest()which could cause a race condition between the buffer allocator’s destruction and the last operation that we perform on a buffer that has been allocated from it. Basically we signal that the last write is complete after we’ve finished fiddling with the buffers that we’ve been using. -
Added conditional code to allow
FILE_SKIP_SET_EVENT_ON_HANDLEandFILE_SKIP_COMPLETION_PORT_ON_SUCCESSto be enabled on the file handle used byJetByteTools::IO::CAsyncFileWriter. See theJETBYTE_PERF_FILE_WRITER_SKIP_EVENT_ON_HANDLEandJETBYTE_PERF_FILE_WRITER_SKIP_COMPLETION_PORT_ON_SUCCESSconfiguration options inConfig.h -
Added conditional code to allow
FILE_SKIP_SET_EVENT_ON_HANDLEandFILE_SKIP_COMPLETION_PORT_ON_SUCCESSto be enabled on the file handle used byJetByteTools::IO::CAsyncFileReader. See theJETBYTE_PERF_FILE_READER_SKIP_EVENT_ON_HANDLEandJETBYTE_PERF_FILE_READER_SKIP_COMPLETION_PORT_ON_SUCCESSconfiguration options inConfig.h -
Fixed
JetByteTools::IO::CBufferAllocator::RequestUserDataSlot()so that it only checks to see if the index collection is locked if an exception is thrown whilst manipulating it. -
Removed <wtypes.h> from
IAsyncIOStream.h -
Added
JetByteTools::IO::CInOrderBufferList::SetInitialSequenceNumber()and allow the initial sequence number to be passed into the constructor. -
Fixed
JetByteTools::IO::CInOrderBufferListsequence number wrap issues. -
Breaking Change All instances of
InitiateShutdown()have been changed toBeginShutdown()this is to remove the issue with the Win32InitiateShutdown()function which is conditionally defined as eitherInitiateShutdownA()orInitiateShutdownW()and which could then cause issues. The following classes are affected: -
JetByteTools::IO::IOPool
Socket Tools Library - 6.2
-
Added
JetByteTools::Socket::CCompressingDatagramSocketConnectionFilter- a filter which uses an instance ofJetByteTools::Win32::ICompressDatato compress the data stream. -
Breaking Change Separated servers and connection managers that support filtering from those that do not. You now need to select a server or connection manager that supports filtering if you want to use connection filters with it. This removes the connection filtering code from those servers that do not use it and provides a slight performance improvement. This was a fairly invasive change as to avoid code duplication we switched to using templates for the server and connection manager base classes. The new classes that support filtering are:
-
JetByteTools::Socket::CFilteringStreamSocketConnectionManager -
JetByteTools::Socket::CFilteringStreamSocketServer -
JetByteTools::Socket::CFilteringStreamSocketServerEx -
JetByteTools::Socket::ICreateFilteredStreamSocketConnections -
Breaking Change to
JetByteTools::Socket::IFilterStreamSocketConnections. Most of the function signatures have changed because we’ve done away with theFilterProcessingenumand now indicate that a filter has ‘swallowed’ a call by simply not returning the buffer that it was passed in. Filter methods now generally return a buffer which is passed on to the next filter in the chain and eventually on to the client code callback. A filter can return any buffer, not just the buffer that it was passed, but it should be sure to copy the sequence number if it replaces the input buffer with one of its own. By returningnullthe filter can signal that the call stops there, it may pass buffers on to later filters directly usingJetByteTools::Socket::IManageStreamSocketConnectionFiltersor simply swallow the request. Note that onlyJetByteTools::Socket::IFilterStreamSocketConnections::RequestRead()differs in that it returns aboolto indicate if processing should continue; this is due to the fact that the input buffer is optional anyway and anullbuffer is no indication of anything special. This change has knock on changes to the following classes as they implement or deal withJetByteTools::Socket::IFilterStreamSocketConnections. -
JetByteTools::Socket::CCompressingStreamSocketConnectionFilter -
JetByteTools::Socket::CConnectionMaintainingStreamSocketConnectionFilter -
JetByteTools::Socket::CFlowControlStreamSocketConnectionFilter -
JetByteTools::Socket::CNullStreamSocketConnectionFilter -
JetByteTools::Socket::CReadSequencingStreamSocketConnectionFilter -
JetByteTools::Socket::CReadTimeoutStreamSocketConnectionFilter -
JetByteTools::Socket::CFilteringStreamSocketConnectionManager -
JetByteTools::Socket::CFilteringStreamSocketServer -
JetByteTools::Socket::CFilteringStreamSocketServerEx -
Added Filtering to datagram sockets. Use
JetByteTools::Socket::CFilteringDatagramSocketServerandJetByteTools::Socket::CFilteringDatagramConnectionManagerif you wish to use filters with datagram sockets. The following filters are currently available: -
JetByteTools::Socket::CCompressingDatagramSocketConnectionFilter- a filter which uses an instance ofJetByteTools::Win32::ICompressDatato compress the contents of each datagram. -
JetByteTools::Socket::CReadTimeoutDatagramSocketConnectionFilter- a filter which provides a read timeout for datagram sockets. -
Breaking Change Renamed
JetByteTools::Socket::TCPBufferSizetoJetByteTools::Socket::SocketBufferSizeas it is now used to set send/recv buffer sizes for datagram sockets as well as TCP (stream) sockets. -
Added
JetByteTools::Socket::IRenderAddresses::GetPort()which returns the port of a given address. -
Fixed a bug in how socket connections were aborted during shutdown. See here for more details.
-
Added new connection closure socket callbacks;
JetByteTools::Socket::IStreamSocketCallback::OnConnectionClosure(),JetByteTools::Socket::IDatagramSocketCallback::OnConnectionClosure()andJetByteTools::Socket::IDatagramServerSocketCallback::OnConnectionClosure()which provide a reason for the connection closure in the form of a value from theJetByteTools::Socket::ConnectionClosureReasonenum. Note thatJetByteTools::Socket::IStreamSocketCallback::OnConnectionClosed(), etc, MAY be removed in a future release of the framework. -
Added
JetByteTools::Socket::ILimitConnections::GetOverallLimit()which returns the total number of connections that a connection limiter allows. -
Moved
JetByteTools::Socket::CConnectionLimiter::NoLimittoJetByteTools::Socket::ILimitConnections::NoLimitso that it can be returned byJetByteTools::Socket::ILimitConnections::GetOverallLimit()for a connection limiter which does not have a limit. -
Added
JetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnBindCompleted()which is called when a datagram socket has successfully been bound to a local address. -
JetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnSocketCreated()is no longer marked as ’no throw’. -
JetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnConnectionEstablished()is no longer passed a pointer to user data. -
Added
JetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnAllConnectionsAborted(),JetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnShutdownInitiated()andJetByteTools::Socket::IDatagramSocketConnectionManagerCallback::OnShutdownComplete(). -
Breaking Change rationalised how server shutdown occurs so that we guarantee that
OnServerShutdownComplete()is only ever called once. -
Breaking Change All instances of
InitiateShutdown()have been changed toBeginShutdown()this is to remove the issue with the Win32InitiateShutdown()function which is conditionally defined as eitherInitiateShutdownA()orInitiateShutdownW()and which could then cause issues. The following classes are affected: -
JetByteTools::Socket::IServerControl -
JetByteTools::Socket::CServerCollection -
JetByteTools::Socket::CNamedServerCollection -
JetByteTools::Socket::CDatagramSocketConnectionManager -
JetByteTools::Socket::CDatagramSocketServer -
JetByteTools::Socket::CStreamSocketConnectionManager -
JetByteTools::Socket::CStreamSocketServer -
JetByteTools::Socket::CStreamSocketServerEx -
Added conditional code to allow
FILE_SKIP_SET_EVENT_ON_HANDLEandFILE_SKIP_COMPLETION_PORT_ON_SUCCESSto be enabled on sockets. See theJETBYTE_PERF_STREAM_SOCKETS_SKIP_EVENT_ON_HANDLE,JETBYTE_PERF_DATAGRAM_SOCKETS_SKIP_EVENT_ON_HANDLE,JETBYTE_PERF_STREAM_SOCKETS_SKIP_COMPLETION_PORT_ON_SUCCESSandJETBYTE_PERF_DATAGRAM_SOCKETS_SKIP_COMPLETION_PORT_ON_SUCCESSconfiguration options inConfig.h -
Added
JetByteTools::Socket::IAcceptDatagramSocketConnectionFilters,JetByteTools::Socket::IFilterableDatagramSocket,JetByteTools::Socket::IFilterDatagramSocketConnectionsandJetByteTools::Socket::IManageDatagramSocketConnectionFiltersto support datagram socket filtering. -
Fixed a memory leak in
JetByteTools::Socket::CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased()where we were deleting avoidpointer rather than casting it to its correct class before deletion. -
Added
JetByteTools::Socket::CReadTimeoutStreamSocketConnectionFilter::SetupReadTimeout()which can be used to set the details of a read timeout without actually setting the timer. -
Added various versions of
JetByteTools::Socket::CSocketReferenceTracker::DumpReferences()to make it easy to dump a socket’s references. OpenSSL Tools Library - 6.2 -
Refactored the code to remove duplication. This resulted in the creation of
JetByteTools::OpenSSL::CSecureConnectShimandJetByteTools::OpenSSL::CStreamSocketConnectionFilter. -
Templatised the code in
JetByteTools::OpenSSL::CStreamSocketServerintoJetByteTools::OpenSSL::TStreamSocketServerto allow the creation ofJetByteTools::OpenSSL::CStreamSocketServerExand the newJetByteTools::OpenSSL::CStreamSocketServer. -
Added
JetByteTools::OpenSSL::CStreamSocketServerExCallback. -
Breaking Change to
JetByteTools::OpenSSL::CStreamSocketConnectionFilterdue to function signature changes inJetByteTools::Socket::IFilterStreamSocketConnections.
SChannel Tools Library - 6.2
-
Refactored the code to remove duplication. This resulted in the creation of
JetByteTools::SSPI::SChannel::CSecureConnectShim,JetByteTools::SSPI::SChannel::CSecureConnectData,JetByteTools::SSPI::SChannel::CFilterHolderandJetByteTools::SSPI::SChannel::CStreamSocketConnectionFilter. -
Templatised the code in
JetByteTools::SSPI::SChannel::CStreamSocketServerintoJetByteTools::SSPI::SChannel::TStreamSocketServerto allow the creation ofJetByteTools::SSPI::SChannel::CStreamSocketServerExand the newJetByteTools::SSPI::SChannel::CStreamSocketServer. -
Added
JetByteTools::SSPI::SChannel::CStreamSocketServerExCallback. -
Breaking Change to
JetByteTools::SSPI::SChannle::CStreamSocketConnectionFilterdue to function signature changes inJetByteTools::Socket::IFilterStreamSocketConnections.
SSPINegotiate Tools Library - 6.2
-
Refactored the code to remove duplication. This resulted in the creation of
JetByteTools::SSPI::Negotiate::CSecureConnectShim,JetByteTools::SSPI::Negotiate::CClientImpersonator,JetByteTools::SSPI::Negotiate::CFilterHolderandJetByteTools::SSPI::Negotiate::CStreamSocketConnectionFilter. -
Templatised the code in
JetByteTools::SSPI::Negotiate::CStreamSocketServerintoJetByteTools::SSPI::Negotiate::TStreamSocketServerto allow the creation ofJetByteTools::SSPI::Negotiate::CStreamSocketServerExand the newJetByteTools::SSPI::Negotiate::CStreamSocketServer. -
Added
JetByteTools::SSPI::Negotiate::CStreamSocketServerExCallback. -
Breaking Change to
JetByteTools::SSPI::Negotiate::CStreamSocketConnectionFilterdue to function signature changes inJetByteTools::Socket::IFilterStreamSocketConnections.
SSPI Tools Library - 6.2
- No changes.
PerfMon Tools Library - 6.2
- Removed the whole broken concept of
JETBYTE_PERFMON_SAFE_BUT_SLOW_64BIT_OPERATIONSwhich allowed 64 bit wide counters to be accessed in a non atomic manner if the variousInterlockedXXX64()intrinsics weren’t available if it was set to zero. Now there’s no way of turning off the lock used to ensure atomic increments of 64 bit values if required. This will prevent 64 bit counter values from being completely broken if compiled withJETBYTE_PERFMON_SAFE_BUT_SLOW_64BIT_OPERATIONSset to zero on a platform that doesn’t supportInterlockedXXX64().
Service Tools Library - 6.2
- Breaking Change to
JetByteTools::Service::IServiceCallbacks::InitialiseService()which now returns abool(rather thanvoid) wherefalseindicates that the initialisation failed and that the service should shutdown.
CLR Hosting Tools Library - 6.2
- Added some initial support for the new hosting API with
JetByteTools::CLRHosting::CCLRMetaHostandJetByteTools::CLRHosting::CCLRRuntimeInfo.
Full details of the licensed version of the code are available at http://wwww.serverframework.com.
Full details of the free version of the code are available here.
Doxygen documentation for the latest relase is available here.
If you’re an existing client and you’d like these changes let me know. I’m currently in the final phases of testing the release. I expect it will be ready to ship by the end of next week at the latest.