Trailing-Edge
-
PDP-10 Archives
-
BB-H348C-RM_1982
-
swskit-v21/demos/server.cbl
There are no other files named server.cbl in the archive.
ID DIVISION.
PROGRAM-ID. SERVER.
AUTHOR. P MIERSWA AND C BENCE
INSTALLATION. DIGITAL MARLBORO.
REMARKS.
This is the server task for a distributed data processing demo.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LOCAL-FILE ASSIGN TO DSK
ACCESS IS INDEXED
SYMBOLIC KEY IS THE-KEY
RECORD KEY IS RECORD-KEY
RECORDING MODE IS ASCII.
DATA DIVISION.
FILE SECTION.
FD LOCAL-FILE
BLOCK CONTAINS 10 RECORDS
VALUE OF ID IS "DATA IDX"
DATA RECORD IS ISAM-RECORD.
01 ISAM-RECORD USAGE DISPLAY-7.
02 RECORD-KEY PIC X(16).
02 RECORD-DATA PIC X(128).
WORKING-STORAGE SECTION.
01 OK-FUNC PIC X.
01 NODE-NAME PIC X(20) USAGE DISPLAY-7 VALUE SPACE.
01 THE-KEY PIC X(16) USAGE DISPLAY-7.
01 NETLN PIC S9(10) COMP VALUE 0.
01 N-TYPE PIC S9(10) COMP VALUE 0.
01 DESC PIC X(40) DISPLAY-7 VALUE SPACE.
01 WAIT PIC S9(10) COMP VALUE 0.
01 RETCOD PIC S9(10) COMP VALUE 0.
01 EOM PIC S9(10) COMP VALUE 0.
01 N-COUNT PIC S9(10) COMP VALUE 0.
01 N-CODE PIC S9(10) COMP VALUE 0.
01 LINK PICTURE S9(10) COMP VALUE 4.
01 DISPLAY-FLAG PICTURE X.
01 DATA-IO.
05 DATA-TYPE.
10 DATA-FUNC PIC X(8) DISPLAY-7.
10 DATA-RETURN PIC 9(8) DISPLAY-7.
05 DATA-RECORD.
10 DATA-KEY PIC X(16) DISPLAY-7.
10 DATA-DATA PIC X(128) DISPLAY-7.
PROCEDURE DIVISION.
START.
DISPLAY "Display network activity (Y or N)? " WITH NO ADVANCING.
ACCEPT DISPLAY-FLAG.
IF DISPLAY-FLAG EQUALS "Y" ENTER MACRO VTINIT.
MOVE ZERO TO RETCOD.
PERFORM ESTABLISH-SERVER-LINK LINK TIMES.
MAIN-LOOP.
MOVE -1 TO NETLN.
CALL NFGND USING NETLN,1,RETCOD.
IF RETCOD > 5
DISPLAY "?Fatal error in NFGND. Error code => ",RETCOD
STOP RUN.
IF RETCOD EQUALS 1 PERFORM DO-NFACC.
IF RETCOD EQUALS 2 OR 5 PERFORM DO-NFCLS.
IF RETCOD EQUALS 3 PERFORM DO-NFRCI.
IF RETCOD EQUALS 4 PERFORM PROCESS-FUNCTION.
GO TO MAIN-LOOP.
ESTABLISH-SERVER-LINK.
MOVE "SRV:.HELPER" TO DESC.
CALL NFOPN USING NETLN,0,DESC,7,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFOPN. Error code => ",RETCOD
STOP RUN.
DO-NFACC.
IF DISPLAY-FLAG EQUALS "Y"
MOVE SPACES TO DATA-IO,NODE-NAME
CALL NFINF USING NETLN,1,N-COUNT,NODE-NAME,RETCOD
DISPLAY " "
DISPLAY " " DISPLAY " " DISPLAY " "
DISPLAY " Accepting Connection From Node => ",NODE-NAME
DISPLAY " Link => ",NETLN
MOVE SPACES TO DATA-IO,NODE-NAME
CALL NFINF USING NETLN,5,N-COUNT,NODE-NAME,RETCOD
DISPLAY " Userid => ",NODE-NAME.
MOVE SPACES TO DATA-IO.
CALL NFACC USING NETLN,0,DATA-IO,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFACC. Error code => ",RETCOD
STOP RUN.
DO-NFCLS.
IF DISPLAY-FLAG EQUALS "Y"
DISPLAY " " DISPLAY " "
DISPLAY " Closing Link => ", NETLN.
CALL NFCLS USING NETLN,0,0,0,DATA-IO,RETCOD.
IF RETCOD NOT EQUAL ZERO
CALL NFCLS USING NETLN,1,0,0,DATA-IO,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFCLS. Error code => ",RETCOD
STOP RUN.
PERFORM ESTABLISH-SERVER-LINK.
DO-NFRCI.
CALL NFRCI USING NETLN,N-COUNT,DATA-IO,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFRCI. Error code => ",RETCOD
STOP RUN.
IF DISPLAY-FLAG EQUALS "Y"
DISPLAY " "
DISPLAY " Interrupt message => ",DATA-IO.
PROCESS-FUNCTION.
MOVE SPACES TO DATA-IO.
CALL NFRCV USING NETLN,160,DATA-IO,1,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFRCV. Error code => ",RETCOD
STOP RUN.
IF DISPLAY-FLAG EQUALS "Y"
DISPLAY " "
DISPLAY " Function requested => ",DATA-FUNC
DISPLAY " Key => ",DATA-KEY.
MOVE " " TO OK-FUNC.
IF DATA-FUNC = "READ "
MOVE "X" TO OK-FUNC
PERFORM READ-RECORD.
IF DATA-FUNC = "WRITE "
MOVE "X" TO OK-FUNC
PERFORM WRITE-RECORD.
IF DATA-FUNC = "DELETE "
MOVE "X" TO OK-FUNC
PERFORM DELETE-RECORD.
IF OK-FUNC EQUALS " "
PERFORM ILLEGAL-FUNCTION.
IF DISPLAY-FLAG EQUALS "Y"
IF DATA-RETURN = ZERO
DISPLAY " Function completed successfully."
ELSE
DISPLAY " Illegal request or request failed.".
ILLEGAL-FUNCTION.
MOVE 9 TO DATA-RETURN.
CALL NFSND USING NETLN,160,DATA-IO,1,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFSND. Error code => ",RETCOD
STOP RUN.
READ-RECORD.
MOVE "READ " TO DATA-FUNC.
MOVE ZERO TO DATA-RETURN.
OPEN I-O LOCAL-FILE.
MOVE SPACES TO ISAM-RECORD.
MOVE DATA-KEY TO THE-KEY.
READ LOCAL-FILE
INVALID KEY MOVE 1 TO DATA-RETURN.
IF DISPLAY-FLAG EQUALS "Y"
DISPLAY " Data => ",RECORD-DATA.
CLOSE LOCAL-FILE.
MOVE RECORD-DATA TO DATA-DATA.
CALL NFSND USING NETLN,160,DATA-IO,1,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFSND. Error code => ",RETCOD
STOP RUN.
WRITE-RECORD.
MOVE "WRITE " TO DATA-FUNC.
MOVE ZERO TO DATA-RETURN.
OPEN I-O LOCAL-FILE.
MOVE DATA-RECORD TO ISAM-RECORD.
MOVE DATA-KEY TO THE-KEY.
WRITE ISAM-RECORD
INVALID KEY MOVE 2 TO DATA-RETURN.
CLOSE LOCAL-FILE.
MOVE SPACES TO DATA-RECORD.
CALL NFSND USING NETLN,160,DATA-IO,1,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFSND. Error code => ",RETCOD
STOP RUN.
DELETE-RECORD.
MOVE "DELETE " TO DATA-FUNC.
MOVE ZERO TO DATA-RETURN.
OPEN I-O LOCAL-FILE.
MOVE DATA-RECORD TO ISAM-RECORD.
MOVE DATA-KEY TO THE-KEY.
DELETE ISAM-RECORD
INVALID KEY MOVE 3 TO DATA-RETURN.
CLOSE LOCAL-FILE.
MOVE SPACES TO DATA-RECORD.
CALL NFSND USING NETLN,160,DATA-IO,1,0,RETCOD.
IF RETCOD NOT EQUAL ZERO
DISPLAY "?Fatal error in NFSND. Error code => ",RETCOD
STOP RUN.
END-OF-IT.
STOP RUN.