TS/MP Pathsend and Server Programming Manual (G06.24+, H06.03+)

Examples
NonStop TS/MP Pathsend and Server Programming Manual132500
B-20
Pathsend Requester Example
?PAGE "COMPLETE THE OUTSTANDING I/O"
! This PROC waits for I/O to complete and returns the address of the
! control block associated with the completion. It returns nil^addr
! if I/O completed with an error, or nil^addr if there was no
! completion (in the case of a timeout, error 40).
DBL PROC complete^io;
BEGIN
INT .EXT cb (control^block^template);
DBL tag := -1D;
DBL timelimit := 300D; ! wait 3 seconds (0.01 sec units)
LIT anyfnum = -1; ! wait on any file
INT fnum; ! used in call to awaitiox
STR .EXT sp;
INT error;
INT .buf [0:79];
STR .sbuf := @buf '<<' 1;
STR .st;
! When waiting for any I/O to complete (fnum = -1) with an AWAITIO
! time limit <> 0, I/O is considered complete and no longer
! outstanding (whether an error is returned or not) in every case
! except when a timeout (error 40) occurs.
!
! When a completion occurs, the file number of the completed call
! is returned in the <fnum> param, and tag is returned in <tag>.
fnum := anyfnum;
CALL AWAITIOX (fnum,,, tag, timelimit);
IF =
THEN ! one I/O successfully completed
BEGIN
@cb := tag;
! Do some basic checks to make sure the control block is what we
! expect. We expect the file number returned by AWAITIOX to be
! the same as the fle number we saved in the control block when
! the I/O was initiated. And we expect the control block to be
! a valid type.
IF cb.fnum <> fnum OR
(cb.type <> cb^type^pathsend AND cb.type <> cb^type^msg^log)
THEN ! assertion failed
CALL abend^with^my^abend^msg;
cb.io^posted := false;
CALL write^trace^file (trace^completed^io, cb.record^number);
RETURN @cb;
END;