In my RCP application I run two plug-ins. Both of them provide a perspective. Both plug-ins use the same socket address (IP + port number) for network communication. When changing perspective the inactive perspective/plug-in must free the socket otherwise the active perspective/plug-in can't initialize its socket.

I have a listener in my RCP application's ApplicationWorkbenchWindowAdvisor which could perhaps take care of the needed action: