def METHOD_NAME(self, af, socktype, proto, canonname, sa):
    s = socket.socket(af, socktype, proto)
    # fail fast with a small timeout
    s.settimeout(self.timeout)
    with contextlib.closing(s):
        try:
            s.connect(sa)
        except socket.error:
            return
    # the connect succeeded, so the port isn't free
    host, port = sa[:2]
    tmpl = "Port {port} is in use on {host}."
    raise PortNotFree(tmpl.format(**locals()))