OSI/TS Configuration and Management Manual

Programming Examples
OSI/TS Configuration and Management Manual424831-001
C-6
TAL Example File-Transfer Program, Responder
! * Main program for the TSP responder
! *
! ******************************************************
PROC m MAIN;
BEGIN
!
! *** Open $RECEIVE, read in the startup message and close
! *** $RECEIVE
call startup;
!
! *** Expand the destination file name
call
fnameexpand(dsex^file^name,dest^file^name,default^subvol);
!
! *** Expand the TSP responder SU name
call fnameexpand(ext^dev^rcv,osi^dev^rcv,default^subvol);
!
! *** Open the TSP responder SU
call open (osi^dev^rcv ,ornum);
!
! *** Set mode for the nowait I/O operation
call setmodenowait(ornum, 30, 1);
!
! *** Ready for accepting a connection request
call control(ornum,11);
!
! *** Purge the existing destination file
call purge(dest^file^name);
!
! *** Create a unstructed destination file
call create(dest^file^name,100,100,20,!p5!,rec^len^rcv);
!
! *** Open the destination file
call open(dest^file^name ,dnum,0,1);
!
! *** Read data sent by the request and store it in the
! *** destination file until the last record is encountered
Do
begin
call read(ornum,buffer,rec^len^rcv + 2,count^read);
call awaitio(ornum);
call write(dnum,buffer[1],count^read -2);
end
!
until buffer.<15> = 0;
!
! *** Close the destination file
call close (dnum);
!
! *** Release the transport connection
call control (ornum,12);
!
! *** Close the TSP SU
call close (ornum);
END;