The client releases the connection similar to the way the server releases it. The client processes incoming data until t_rcv() fails. When the server releases the connection (using either t_snddis() or t_sndrel()), t_rcv() fails and sets t_errno to TLOOK. The client then processes the connection release as follows:
if ((t_errno == TLOOK) && (t_look(fd) == T_ORDREL)) { if (t_rcvrel(fd) == -1) { t_error("t_rcvrel failed"); exit(6); } if (t_sndrel(fd) == -1) { t_error("t_sndrel failed"); exit(7); } exit(0); } |
Each event on the client's transport endpoint is checked for an orderly release request. When one is received, the client calls t_rcvrel() to process the request and t_sndrel() to send the response release request. The client then exits, closing its transport endpoint.
If a transport provider does not support the orderly release, use abortive release with t_snddis() and t_rcvdis(). Each user must take steps to prevent data loss. For example, use a special byte pattern in the data stream to indicate the end of a conversation.