Testing the New Connection
Code in both processes (A and B) must test the new connection before using it. Use the following two-part test. Immediately after creating a virtual circuit terminal object, do these two steps, in this order:
Procedure
1. | Listen for the VC.CONNECTED advisory on the terminal transport object. If the terminal presents this advisory, it is ready to use. |
It is possible to miss this advisory. That is, the terminal might present it before the program creates the listener to intercept it. In this situation, the program could wait indefinitely for the advisory, which has already come and gone. To avoid this situation, do the following step as well.
2. | Poll the connection to test whether it is operational, supplying zero as the timeout parameter to the wait-for-connection call. If this call returns without error, the terminal is ready to use. |