Pathway/iTS TCP and Terminal Programming Guide
Processing Unsolicited Messages
Compaq NonStop™ Pathway/iTS TCP and Terminal Programming Guide—426751-001
7-7
Using Waited RECEIVE UNSOLICITED Statements
Using Waited RECEIVE UNSOLICITED Statements
Another way of detecting the arrival of unsolicited messages is to branch to a paragraph 
that issues a RECEIVE UNSOLICITED MESSAGE statement; the statement may or 
may not include a TIMEOUT clause. If there are no unsolicited messages currently 
queued, the RECEIVE UNSOLICITED statement acts as a waited input request 
comparable to ACCEPT. If the statement does not include a TIMEOUT clause, it waits 
indefinitely for a message. If the statement includes a TIMEOUT clause and the 
specified timeout period elapses without the receipt of an unsolicited message, control 
passes to the ON ERROR code, if present. If there is no ON ERROR paragraph, the 
requester suspends.
This approach has two apparent drawbacks when compared with the preceding example: 
it processes only a single message, regardless of how many might currently be on the 
queue, and it causes the requester to halt either indefinitely or up to the specified timeout 
period if the queue is empty and no unsolicited message arrives. This is a valid 
approach, however, that might be appropriate in certain application environments.
 .
 .
 .
 PERFORM CHECK-FOR-UNSOLICITED-MESSAGE.
 .
 .
 CHECK-FOR-UNSOLICITED-MESSAGE.
 RECEIVE UNSOLICITED MESSAGE
 YIELDS ws-unsolicited-message
 TIMEOUT one-minute
 ON ERROR GO TO analyze-error.
* Do something with ws-unsolicited-message
* and format a reply message.
 REPLY TO UNSOLICITED MESSAGE reply-message.
 ANALYZE-ERROR.
 IF TERMINATION-STATUS = 1 and
 TERMINATION-SUBSTATUS = 40
* The statement timed out, which in this
* case is not really an error condition;
* at the very least you must specify some
* kind of declarative clause here, such as
* MOVE TIMED-OUT TO LATEST-COMPLETION, even
* if it amounts to a no op.
 ELSE
* Respond appropriately to other types
* of errors.
If a message arrives before the RECEIVE UNSOLICITED statement times out, the 
message is moved to ws-unsolicited-message in working storage and control 
proceeds with the statements immediately following the RECEIVE UNSOLICITED 
statement.










