Overview
This page discusses the concept of connections and how to handle them.
Introduction
Even though UDP is connectionless, the framework builds the illusion of a connection. EM_NET_CONNECTION encapsulates everything that's needed to manage network connections. An important mechanism is that connections can join several groups if needed. This is explained later.
Usage
There are two different ways to create and add a connection manually to a group:
- create_connection with a reference to an EM_INET_SOCKET_ADDRESS. This creates a dynamic connection, which means that the internal timeout mechanism will check for timeouts. A timeout occurs as soon as there is no incoming traffic on a connection for a specific time.
- create_static_connection creates a connection which is not monitored by the default timeout mechanism. However, you can still implement a timeout mechanism which suits your needs.
If you want to delete a connection you simply use the feature delete_connection providing a reference to an existing connection.
Each connection has its "personal group" (see: personal_group), which does not imply that it is the only member of this group: If you want to implement a logger, which logs all events which are directly sent to a certain peer, you can simply add the logger to its personal group.