[Top] [Prev] [Next] [Bottom]


7 - Unregistering the Application

Before exiting, your application must unregister from the portmappers and event dispatchers where it has previously registered. Failure to unregister with the portmapper results in old transient RPC program numbers being kept needlessly. Failure to unregister with the event dispatcher causes the dispatcher to continue to process event reports for your nonexistent process, consuming system resources.


7.1 Unregistering from the Event Dispatcher

If you have registered with the event dispatcher, always unregister the event rendezvous before unregistering any transient RPC program numbers. Use the call netmgt_unregister_rendez(3n) to tell the event dispatcher you are no longer interested in events. The event dispatcher keeps a list of its registered applications by the parameters sent to it with the netmgt_register_rendez(3n) call, so use the same parameters to unregister.


7.2 Unregistering the Transient RPC

If you have registered with the portmapper, call netmgt_unregister_callback (3n) to give back your transient RPC program number. Unlike netmgt_unregister_rendez (3n), the call to unregister your callback function only requires your transient RPC number and version (which is probably NETMGT_VERS).

If your application has a permanent registration with the portmapper you do not need to unregister your RPC program number.


7.3 Sample Code

Here's an example code fragment to unregister the report handler registered earlier in the document:


/* Unregister the event manager rendezvous, 
 * using the same parameters we registered with: 
 */ 
if (!netmgt_unregister_rendez(myname, 
        myname, rendez, NETMGT_VERS, 
        NETMGT_ANY_AGENT, NETMGT_LOW_PRIORITY, 
        timeout)) 
(void)fprintf(stderr, "Can't unregister from the event dispatcher: %s\n", 
        netmgt_sperror()); 
(void) netmgt_unregister_callback(rendez, NETMGT_VERS);
 



[Top] [Prev] [Next] [Bottom]

Copyright 1996 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043-1100 USA. All Rights Reserved