FORTRAN Reference Manual
Interprocess Communication
FORTRAN Reference Manual—528615-001
14-15
Message Queuing
The source for the queued server is shown in Example 14-2 on page 14-17.
The UNIT directive at line 2 assigns unit 7 to the data file. When you run the server, 
you must specify $RECEIVE for both the IN file and the OUT file.
The RECEIVE directive at line 3 defines the saved reply table as follows:
•
OPEN 4: Not more than four processes are allowed to have the server process 
open at any given time. Any additional OPEN attempts will be refused with file 
management error 12.
•
QDEPTH 4: The server may read up to four requests without responding to any. An 
attempt to read another request while four requests are outstanding results in a file 
management error 74.
•
SYNCDEPTH 2: The FORTRAN run-time library routines save two replies per 
requester to support NonStop requester processes. An attempt by a requester to 
open the server using a SYNCDEPTH greater than two will be refused with a file 
management error 28.
•
MAXREPLY 200: The longest reply the server can issue is 200 characters. 
•
SYSMSG: The server will process system messages itself, rather than having the 
run-time support system reply to them automatically.
At lines 32 through 34, the server initializes its list of pending requests. At lines 35 
through 37, it opens its files.
Statement label 10 at line 38 is the beginning of the server’s main loop. At line 39, it 
reads the next record from its data file. The MATCHOLD function, invoked at line 41, 
determines whether a request for the current record has already been received. If so, 
then:
1> RUN QSO /NAME $DIST, CPU 0, IN $RECEIVE, OUT $RECEIVE/
2> RUN R1O /NAME $R1, CPU 0, IN $DIST/
3> RUN R2O /NAME $R2, CPU 0, IN $DIST/
R1 ABOUT TO MAKE FIRST REQUEST.
4> PAUSE
R2 ABOUT TO MAKE FIRST REQUEST.
R1 1 3 5 7 * 1  1
R2 2 4 6 * 2  2
R2 2 4 6 * 2  3
R1 1 3 5 7 * 7  4
R2 2 4 6 * 6  5
R1 1 3 5 7 * 5  6
R2 2 4 6 * 4  7
R1 1 3 5 7 * 3  8
R2 2 4 6 * 2  9
R1 1 3 5 7 * 1  10
R2 2 4 6 * 4  12
R1 1 3 5 7 * 3  11
R2 STOPPING
R1 STOPPING
END OF QUEUEING SERVER RUN
5>










