Beginning a Session
The first thing to do to use the CIGI Class Library is to create a session object.
The session object must be either a host session or an IG session.
You may specify the number of outgoing message buffers and the size of these buffers
and the number of incoming message buffers and the size of these buffers. If you do not specify
the number and size of these buffers, two buffers of each type are created and
each buffer is 16kb in size.
The size of a single outgoing buffer is the maximum size of any outgoing message.
If the user creates a larger message than the buffer, the overflowing packets are
placed in the next buffer. If the user fills all of the available buffers, a new buffer is
created and the overflowing packets are placed in this new buffer.
Warning: It is possible to get into a runaway buffer creation condition causing the
system to abort the program.
If the program is using the provided incoming message buffers, the size of a single incoming
message buffer is the maximum size of an incoming message. Otherwise, if the program is
supplying its own incoming message buffer, the size of the supplied incoming message buffer
is the maximum size of an incoming message. The user should never overflow the incoming
message buffer. If a message is received that is larger than the buffer, the user must only
put the portion of the message into the incoming message buffer that will fit.
The session creates an outgoing message object and an incoming message object. It
also creates several needed tables and buffers. You can create the session by using
any of the C++ object creation methods.
Example: IG session object creation |
CigiIGSession IGsession;
CigiIGSession IGsession(
Number_of_input_buffers,
Size_of_each_input_buffer_in_bytes);
CigiIGSession IGsession(
Number_of_output_buffers,
Size_of_each_output_buffer_in_bytes);
CigiIGSession *IGsessionPnt;
...
IGsessionPnt = new CigiIGSession;
CigiIGSession *IGsessionPnt;
...
IGsessionPnt = new CigiIGSession(
Number_of_input_buffers,
Size_of_each_input_buffer_in_bytes);
IGsessionPnt = new CigiIGSession(
Number_of_output_buffers,
Size_of_each_output_buffer_in_bytes);
|
|
|
Example: Host session object creation |
CigiHostSession HostSession;
CigiHostSession HostSession(
Number_of_input_buffers,
Size_of_each_input_buffer_in_bytes);
CigiIGSession IGsession(
Number_of_output_buffers,
Size_of_each_output_buffer_in_bytes);
CigiHostSession *HostSessionPnt;
...
HostSessionPnt = new CigiHostSession;
CigiHostSession *HostSessionPnt;
...
HostSessionPnt = new CigiHostSession(
Number_of_input_buffers,
Size_of_each_input_buffer_in_bytes);
HostSessionPnt = new CigiHostSession(
Number_of_output_buffers,
Size_of_each_output_buffer_in_bytes);
|
|
|
The user must set the initial version of CIGI that the external interface is
using and set whether the interface is synchronous or asynchronous. The default
is for the session to be synchronous.
Example: Setting the version and synchronization mode |
Session.SetCigiVersion(CIGI_major_version_number,CIGI_minor_version_number);
Session.SetSynchronous(true_or_false);
|
|
|
The user may also create an IO class derived from the CigiIO class. This class must
provide the virtual Read and Write methods that handle the actual buffer output and input.
The CigiIO methods Send and Receive, inherited by the user's IO class, handle most
of the high level buffer management. The user creates and manages the user's IO object.
A simple example of this is the class ExampleIO in the example code. If the user
chooses not to create an IO class, the user must perform all the functions that
Send, Receive, Read, and Write provide.
|
|