The application must initialize the LayGO protocol stack to make protocol services available. The application initializes the stack by calling the API function lgo_InitializeStack(). Stack initialization accomplishes a number of important tasks:
Prior to initializing the stack, the application can set configuration parameters for the hardware, buffer pool, system stack and protocol layers. Configuration profiles can be prepared in advance and loaded from disk at runtime using the API function lgo_ConfigureStack(). (Configuration files are created and edited using the utility program edcfg. See Using edcfg in the LayGO Configuration Manual). Alternatively, lgo_SetDefaultConfiguration() can be used to configure the stack without using configuration files.
Once the stack has been initialized, a call to lgo_EnableStack() enables stack activation.
The function dlg_InitializeStack() in the dlaygo sample program, illustrates a typical sequence of events.
At program termination, lgo_UninitializeStack()
must be called to free memory and other system resources, shut down the
communication hardware and uninstall any interrupt service routines.
If the application terminates using the standard C Library function
the standard C Library function
atexit() can be used to register a function
which will automatically call lgo_UninitializeStack() at termination. In some operating
environments, if an application aborts without performing its exit routine,
the computer may need to be rebooted.
The dlaygo sample program illustrates this technique by
registering the function dlg_AtExit() using