OSI/FTAM Programming Reference Manual

NonStop FTAM Programming Examples
HP NonStop OSI/FTAM Programming Reference Manual528611-001
G-6
Example 2—Moving a File Between Two Remote
Systems (in Wait Mode)
Example 2—Moving a File Between Two Remote Systems (in
Wait Mode)
This programming example illustrates moving a simple binary file. This example
implements the routines for moving an FTAM-3 file from one remote system to another
remote system on the network. The FTAM routines used in this example operate in
wait mode. The example does the following:
1. Establishes an APS segment.
2. Initializes an association with the source system.
3. Initializes an association with the destination system.
4. Selects the source file.
5. Reads the file attributes from the source file.
6. Opens the source file.
7. Creates the destination file, using file attributes based on the source file attributes.
8. Opens the destination file.
9. Sends a write request to the destination.
10. Sends a read request to the source.
11. Receives a cancel indication from the source, and then sends a cancel response to
the source, sends a cancel request to the destination, and receives a cancel
confirm from the destination.
or
Receives a data indication from the source and sends a data request to the
destination.
or
Receives a data end indication from the source and sends a data end request to
the destination.
12. Terminates the transfer of data from the source file.
13. Terminates the transfer of data to the destination file.
14. Closes the destination file.
15. Changes the destination file attributes on the basis of the source file attributes.
Note. It is also possible to receive a cancel indication from the destination system. This
example program does not formally handle cancel indications from the destination system.
If the destination system sends a cancel indication, you will detect it in the return code
from a data request to the destination system. In this case, the example program discards
the association—a program task that is not reflected in the following protocol diagram. The
diagram shows only the final discard that is normally done after terminating an association.