# Setting up the Natural Access environment

The Digital Trunk Monitor service is a C function library component of Natural Access. It is implemented as the DTM service and managed by the ADI service manager.

The DTM service is a DLL under Windows and a shared library under UNIX. You must have Natural Access, including the ADI service, installed on your system to build and run applications using the DTM service.

To set up a Natural Access application:

1. Initialize the Natural Access application.

2. Create event queues.

3. Create contexts for each event queue.

4. Open services on each context.

To set up one or more additional Natural Access applications that share a context with the first application:

1. Initialize the Natural Access application.

2. Create event queues.

3. Attach to the existing context that the applications will share.

Note: For more information on setting up applications, refer to the Natural Access Developer's Reference Manual.

Services are opened on a context by calling ctaOpenServices, passing a context handle and a list of service descriptors. Each service descriptor specifies the name of the service, service manager, and service-specific arguments.

The call to ctaOpenServices is asynchronous and returns immediately. When all services are open, CTAEVN_OPEN_SERVICES_DONE is returned to the application. Natural Access supports opening and closing services on an as-needed basis to share scarce resources.

There can be only one open instance of each service per context. Once the DTM service is open, the application functions invoke the DTM service. The following illustration shows an example of a context with the DTM and ADI services open. The DTM service is associated with trunks on two telephony boards.

Natural Access with the ADI service and the DTM service

ctaCloseServices closes one or more services on a context. The function is asynchronous and returns immediately. You must wait for the completion event CTAEVN_CLOSE_SERVICES_DONE to be returned on the event queue before you can assume that the specified services are closed. An application can close or re-open one service at a time without affecting other open services.

ctaDestroyContext destroys a context. All currently opened services on the context are closed. The function is asynchronous and returns immediately. You must wait for CTAEVN_DESTROY_CONTEXT_DONE to be returned on the event queue before assuming that the context is destroyed and resources are released.

ctaDestroyQueue destroys the queue and all contexts associated with the queue. This is a synchronous function, so the application remains blocked until all clean up and close activity is completed. If the services and contexts are already closed, the function returns immediately.