private void exchangeLock() throws IOException {
        if (config.isDebugOn())
            System.err.println("Attempting to get lock from the hub.");

        //getting the 'lock' string from the hub.
        String lockString = hubComm.getHubData();

        if (config.isDebugOn())
            System.err.println("received lock. value is "+lockString);

        sendSupportedFeatures();

        //sending key to hub
        if (lockString != null) {
            if (config.isDebugOn())
                System.err.println("Sending key to hub...");
            String key = NMDCUtil.generateKey(lockString);
            hubComm.sendDataToHub("$Key "+key+"|");
            if (config.isDebugOn())
                System.err.println("value of key is "+key);
        }
    }