IrDA disconnection is a fairly complex procedure but is much simplified using the Symbian platform IrDA Sockets API.
To disconnect a MUX connection, a call to the asynchronous function RSocket::Shutdown() is made. The detailed behaviour resulting from a call to RSocket::Shutdown() depends on the currently loaded protocol set. To the application programmer, there is no difference.
An “IrTinyTP” shutdown sends any outstanding data before initiating a MUX level disconnect.
An “IrMUX” shutdown throws away all outstanding data and then initiates the MUX level disconnect.
If more than one socket is open, a MUX level disconnection is all that occurs upon shutting down a socket. If, however, only one MUX connection is up, both MUX and IrLAP level disconnections are necessary and completion of the shutdown request occurs when both disconnect operations have completed.
On successful completion of a shutdown, a call to RSocket::Close() can be made. The close operation is queued as an synchronous request so no wait for completion is necessary. If a call to RSocket::Close() is made without a prior call to RSocket::Shutdown(), an “IrTinyTP” socket initiates an immediate disconnection discarding any buffered data it may be holding.