7.5.2 Example: Ending a Hierarchical Conversation
The following figure shows a hierarchical conversation that terminates gracefully.
Figure 7-3 Connection Hierarchy
In the preceding example, service B is a member of a conversation that has initiated a connection to a second service called C. In other words, there are two active connections: A-to-B and B-to-C. If B is in control of both connections, a call to tpreturn() has the following effect: the call fails, a TPEV_SVCERR
event is posted on all open connections, and the connections are closed in a disorderly manner.
In order to terminate both connections normally, an application must execute the following sequence:
- B calls tpsend() with the
TPRECVONLY
flag set on the connection to C, transferring control of the B-to-C connection to C. - C calls
tpreturn()
withrval
set toTPSUCCESS
,TPFAIL
, orTPEXIT
, as appropriate. - B can then call
tpreturn()
, posting an event (eitherTPEV_SVCSUCC
orTPEV_SVCFAIL
) for A.
Note:
It is legal for a conversational service to make request/response calls if it needs to do so to communicate with another service. Therefore, in the preceding example, the calls from B to C may be executed using tpcall() or tpacall() instead of tpconnect(). Conversational services are not permitted to make calls to tpforward().Parent topic: Ending a Conversation