Add new functions to get difference and shared keys between objects,
plus get port number from arguments if it's supplied
and make sure the port number is valid.