Adding checks on the port number to make sure it is valid.