Class CProtocolStack

#include "CProtocolStack.h"

The CProtocolStack class encapsulates supervisory access to the LayGO protocol stack. There should be only one CProtocolStack object in existence at any time.

CProtocolStack simplifies stack control into just 2 operations:

Start() takes a list of configuration file names and, optionally, the name of an alternate service database. It configures, intializes and enables the protocol stack and initializes the service database. If a failure occurs configuring the stack with any file in the file list, a CStackConfigurationException is thrown. If any other error is encountered, a CStackException is thrown. Stop() undoes everything done by Start().

This results in the stack initialization code shown below:

try
{
    CProtocolStack stack;

    stack.Start(cfgCount, cfgList);

    Process();

    stack.Stop();
}
catch (CStackConfigurationException & exception)
{
    cerr << "Stack configuration failure with file '"
         << exception.GetFileName()
         << "': "
         << exception.GetMessage()
         << "."
         << endl;
}
catch (CStackException & exception)
{
    cerr << "Stack initialization failure: "
         << exception.GetMessage()
         << "."
         << endl;
}