This example continues the theme that was started with the UDP Pseudo Connection Server
example and builds a UDP server that builds a slightly more complex 'virtual connection' over a stream of UDP datagrams from the same client. The basic structure of this server is similar to the UDP Pseudo Connection Server
example and you should go and read about that first and have a good understanding of how everything fits together. This document will only cover the differences between the UDP Pseudo Connection Server
example and this example.
This example is shipped with all licensed versions of The Server Framework and it requires the core server framework libraries (see here
for licensing options). You can always download the latest version of this example from here
; and although you will need the correct libraries to be able to build it you can look at the example code and see how it works and perhaps get ideas from it. A compiled, unicode release, build of this example is available on request if you require it for performance analysis of the framework.
This version of the server has a slight performance advantage over the previous
example as it can use a CSingleWriterMultipleReaderLock
to protect the collection of PerConnectionData rather than a CCriticalSection
. It does this by requiring each datagram in the "virtual connection" to contain a connection id. Only the initial datagram for a connection requires that the collection be locked for writing and all subsequent lookups only require a read lock. This results in better performance as most of the datagrams that are processed do not require exclusive access to the collection and so less blocking occurs between threads.
Obviously in a real server you would store more information in the PerConnectionData.