Passing data to a server program

A buffer object—CclBuf is used in the Client application to encapsulate the communication area that is used for passing data to and from a server program. The use of buffer objects is not limited to communication areas; they offer considerable flexibility for general-purpose data marshaling.

The following code constructs a buffer object and dynamically extends it as text strings are assigned, inserted and appended to its data area:
CclBuf comma1;
comma1 = "Some text";
comma1.insert( 9,"inserted ",5 ) += " at the end";
cout << (char*)comma1.dataArea() << endl;
  …
Output produced:
Some inserted text at the end
In the next example, an existing memory structure is used. This could, for example, correspond to a record used in the server program. In this case, the buffer object knows the record is fixed-length, externally-defined, and ensures it can not be extended in any subsequent processing. The link call requests execution of the program QVALUE on the CICS® server defined by the serv2 connection object and passes data via the structure on which the buffer object comma2 is overlaid.
struct rec{
         short key;
         char name[8];
         char retval[70];
         };
rec record1 = { 1234,"Hilary" };
CclBuf comma2( sizeof(rec),&record1 );
serv2.link( sflow,"QVALUE",&comma2 );
  …

The communications area returned from a server is also contained in a buffer object.