getPort() returns -1 when undefined