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

Example Servers - UDP Servers

These are servers that come with the base server framework release. They consist of a selection of example UDP servers that demonstrate various designs for UDP servers including connection oriented servers.
These examples require the core server framework libraries (see here for licensing options). You can always download the latest version of these examples from here; and although you will need the correct libraries to be able to build them you can look at the code and see how it works and perhaps get ideas from it. Compiled, unicode release, builds of the examples are available on request if you require them for performance analysis of the framework.

  • EchoServerUDP - The basic UDP echo server.
  • EchoServerUDPTest - A UDP client.
  • EchoServerUDPMultiCast - A multicast UDP server.
  • EchoServerUDPMultiCastTest - A multicast UDP client.
  • Examples-UDPGatewayServer"UDPGatewayServer" - A server which accepts inbound reqests from clients and sends a datagram to another server, waits for a response and then sends the response back to the original client.


The examples above deal with UDP servers that work in terms of individual datagrams. It's often common to build a connection oriented system such that a stream of datagrams from a single client might represent a continuous conversation rather than a sequence of isolated datagrams. Whilst there may be issues around 'connection oriented UDP streams' with regards to reliable NAT traversal and firewalls these aren't addressed in the following examples which will reliably work on direct connections between a client and a server on the same network segment.

  • UDPPseudoConnectionServer - A UDP server that uses the client's address and port to separate datagrams into 'connection oriented UDP streams' and uses a per stream read timer to determine when a connection has ended.
  • UDPPseudoConnectionServerTest - A client for the above server which can initiate multiple concurrent UDP streams.
  • UDPPseudoConnectionServer2 - A UDP server that uses an explicit 'connection id' within each datagram to separate datagrams into 'connection oriented UDP streams' and uses a per stream read timer to determine when a connection has ended. Note that this server is slightly more performant than the previous one as it can use a Single Writer, Multiple Reader, lock rather than the mutual exclusion lock that the previous server uses to manage its connection collection.
  • UDPPseudoConnectionServerTest2 - A client for the above server which can initiate multiple concurrent UDP streams.


The examples above are all structured in such a way that the server receives all datagrams on a single well known port and demultiplexes them based on either address or connection id. The following examples take a slightly different approach which is to bind a new socket for each new connection so that each connection sends data to its own server socket. This makes for a more efficient server as the demultiplexing is done in the kernel and each connection has its own socket recv buffer, but it is potentially more complex from a NAT traversal point of view.

  • UDPConnectionServer - A UDP server that uses the client's address and port to separate datagrams into 'connection oriented UDP streams' and uses a per stream read timer to determine when a connection has ended. When a new connection is detected a new socket id created on the server and the response from the new connection is sent on the new socket; the client is expected to detect this and switch to the new port and use that for all future datagrams on that logical connection.
  • UDPConnectionServerTest - A client for the above server which can initiate multiple concurrent UDP streams and correcly detects the implicit port change.
  • UDPConnectionServer2 - A UDP server similar to the one above that uses an explicit 'change port' response message which contains details of the connection's new port. The client can then instigate the switch to the new server port - this works if the client is behind certain kinds of NAT where the client and server above will fail.
  • UDPConnectionServerTest2 - A client for the above server which responds to the port switch message to continue the connection on the new port.


A full list of all of the example servers available can be found here: Example Servers

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