Handling COMMAREAs in Visual Basic
A COMMAREA is a block of storage that contains all the information you send to and receive from the server.
The amount of data sent may differ from the amount of data received,
so you must create a COMMAREA that is big enough for the larger of
the two.. For example, you might need to send a 12 byte serial number
to the server, but receive a maximum of 20 Kb back from the server;
this means you must create a COMMAREA of size 20 Kb. To do this you
could code:
Set Buf = new CclOBuf ' create extensible buffer object
Buf.SetString(serialNo)
Buf.setLength(20480) ' stores Nulls in the unused areaIn the above example, the COMMAREA is given the serial number and the buffer is increased to the required amount, but the extra area is filled with nulls. This is important as it ensures that the information transmitted to the server is kept to a minimum. The client daemon strips off the excess nulls and only transmits the 12 bytes to the server.