Detecting client termination

The last scenario is where a server process wants to be notified of any clients that terminate so that it can clean up any resources that it had set aside for them.

This is very easy to do if the server process is written as a resource manager, because the resource manager's io_close_dup() and io_close_ocb() handlers, as well as the ocb_free() function, will be called if a client is terminated for any reason. For more information, see Writing a Resource Manager.

If the server process isn't a resource manager, it can pass the _NTO_CHF_DISCONNECT flag when it calls ChannelCreate(). This tells the kernel to deliver a pulse when a client process disconnects from the server. If the server is using name_attach(), that function automatically sets this flag.