kNet Documentation


Document version 2.5

kNet is a connection-oriented network protocol for transmitting arbitrary application-specific messages between network hosts. It is designed primarily for applications that require a method for rapid space-efficient real-time communication.

kNet consists of two major specifications. At a lower level, the Transport-level specification defines methods like:

Building on top of that, the Application-level specification, along with a reference C++ implementation, offers most notably the following features:

These two specifications and the reference implementation form a complete base on which to build a networking server+client application. Alternatively, only the Transport-level specification can be used, while replacing the application-level features with a different model. The implementation exposes the library that it uses internally for data serialization, but it is possible to use any other solution as well. There are plenty of choices available: boost serialization, CodeSynthesis XSD, Eet, gSOAP, MFC, Google protobuf, Qt QDataStream, s11n, Poco Serializer, Sweet Persist, tpl, xserial, yaml-cpp, or integrate your own.

This documentation was generated as a part of the C++ reference implementation of the protocol. More information can be found in the following topic pages.

Transport-level specification Application-level specification C++ reference implementation and examples

The following samples demonstrate how to use the protocol library.

Code Samples

SimpleChatA simple example of client<->server message passing.
GroupChatServerImplements a multi-user chat server that broadcasts messages between each participant.
GroupChatClientImplements a multi-user chat client.
ConnectFloodStress tests a server by hammering it with several simultaneous connections.
LatencyTestMeasures the network latency between two hosts.
SpeedTestMeasures the network bandwidth from one host to another.
FileTransferA command-line utility to copy files from one host to another.
MessageCompilerA command-line tool to generate C++ headers out of protocol message XML description files.
TwoStreamsMix lossy high priority message streaming with low priority background data transfer.
PoorNetworkAsserts that message ordering and reliability work in lossy and jittery network conditions.
SpeexVoipShows how to use speex to implement voice communication for multiple users.
TrashTalkA client/server that floods the peer with random data.


Downloadable prebuilt packages of the library or the samples are not yet available. The official source repository of kNet is hosted at .

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines