Added logic to manage connections based on the comm type, secure, unsecure or mixed