# eXtremeDB ARF Applications

> As explained in the ARF introduction page, eXtremeDB Active Replication Fabric provides APIs for implementing automatic or on-demand data exchange between collection points and servers. Generally speaking, IoT applications implement the following steps to utilize ARF:

> > 1. Initialize the ARF runtime. In fact, this creates an internal virtual callback functions table

> > 2. Create and connect to the database

> > 3. Create the communicator object. The communicator object takes care of all interactions with the underlying network layers (sockets)

> > 4. Create the replicator object. The replicator manages the replication process and interfaces with the communicator on one side and with the database on the other

> > 5. Register the callbacks. The callbacks are the means to react to network events such as: connect / disconnect, data transmission (received / sent) and protocol acknowledgments

> > 6. Activate network communications through listen or connect operations

> > 7. While managing the database in the “normal” fashion, from time-to-time react to a notification callback, or explicitly call ARF replicator functions for sending (push), or receiving (pull) data stored locally, and cleaning up aged data (that was replicated and confirmed by the peer)

> > 8. Terminate the replicator and the communicator

> The communicator and the replicator objects belong to the process that creates them; they are not shared between multiple processes. In principal a process can create multiple communicators and/or replicators in pairs (see the diagram below). However, in practice, there is no need because these objects can be used in multiple parallel tasks. Note that the communicator is capable of listening on multiple sockets that are configured differently (different ports, secure or non-secure socket, TCP/IP or local socket).

> Registered callbacks are invoked by the communicator in response to various network events. The replicator callback is registered first during the ARF runtime initialization. In addition the application can register its own callbacks to handle events. For example, to synchronize nodes when establishing a network connection, or to erase “aged” data from the device container upon receiving an acknowledgment from the server. The callbacks are run in the context of the communicator’s service tasks, the number of which is specified when creating the communicator.

> The APIs for ARF applications are specific to the programming language used. Please use the links below to view detailed explanations and examples for your development environment:

> C | ARF (IoT) Applications in C
> Python | ARF (IoT) Applications in Python