protected void close(){
        try{
            connected = false;
            switch(type){
                case RMI:               
                    RMIClientCallback = null;
                    RMICallback = null;
                    RMIClient = null;
                    Naming.unbind(name);            
                    RMIServer = null;                      
                    break;
                case Corba:
                    if(CORBAServer != null){
                        CORBAServer.close();
                        CORBAServer = null;
                    }
                    if(CORBAClient != null){
                        CORBAClient.close();
                        CORBAClient = null;
                    }                    
                    break;
                case SocketUDP:
                    if(d!= null) d.close();
                    d = null;
                    break;                    
                case SocketTCP:
                    if(s!= null) s.close();
                    s = null;
                    break;
            }          
        }catch(Exception e){
            e.printStackTrace();
        }
    }