def port(self):
        """
        Return the port number to connect to, using C{self._port} set up by
        C{listen} if available.

        @return: The port number to connect to.
        @rtype: C{int}
        """
        if self._port is not None:
            return self._port.getHost().port
        return findFreePort(self.interface, self.family)[1]

        Return the port number to connect to, using C{self._port} set up by
        C{listen} if available.

        @return: The port number to connect to.
        @rtype: C{int}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_tcp.py