Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 20
Getting Information About Messages Read
From $RECEIVE
The following example extracts the type of operation requested in the message:
STRUCT .INFORMATION(ZSYS^DDL^RECEIVEINFORMATION^DEF);
.
.
ERROR := FILE_GETRECEIVEINFO_(INFORMATION);
IF ERROR <> 0 THEN ...;
CASE INFORMATION.Z^IOTYPE OF
BEGIN
ZSYS^VAL^RCV^IOTYPE^SYSTEMMSG ->!System message
ZSYS^VAL^RCV^IOTYPE^WRITE ->! Write request
ZSYS^VAL^RCV^IOTYPE^READ ->!READ[X] request
ZSYS^VAL^RCV^IOTYPE^WRITEREAD ->!WRITEREAD[X] request
OTHERWISE ->!Error
END;
Getting the Maximum Reply Count
The maximum reply count indicates the number of reply bytes expected by the sender.
If the message received on $RECEIVE was generated by a WRITEREAD[X] procedure
call, this value is the read-count value specified by the sender in the
WRITEREAD[X] procedure call. If the sender issued a WRITE[X] call, then the
maximum reply count is zero. The value can be nonzero for a READ[X] request or for
a system message.
The value is returned by the FILE_GETRECEIVEINFO_ procedure in word 1. Your
server process can use this value to ensure that the reply does not get truncated when
read by the requester or to adjust a variable-length reply to the expected reply size.
The following example checks the size of the reply data and compares it with the
expected reply size. If the reply data is larger than the expected reply size, then the
server returns error number 300 to the requester to inform the requester that the data
is truncated.
STRUCT .INFORMATION(ZSYS^DDL^RECEIVEINFORMATION^DEF);
.
.
!Get the expected reply length:
ERROR := FILE_GETRECEIVEINFO_(INFORMATION);
IF ERROR <> 0 THEN ...;
!Set error if reply longer than expected reply:
SBUFFER ':=' "Reply to Message" -> @S^PTR;
WCOUNT := @S^PTR '-' @SBUFFER;
IF WCOUNT > INFORMATION.Z^MAXREPLYCOUNT THEN ERROR := 300
ELSE ERROR := 0;
!Reply to requester:
CALL REPLY(SBUFFER,
WCOUNT,
!count^written!,
!message^tag!,