def tcp_listener(address, backlog=None):
    backlog = backlog or 128

    if util.is_ipv6(address[0]):
        family = socket.AF_INET6
    else:
        family = socket.AF_INET

    bound = False
    if 'TPROXY_FD' in os.environ:
        fd = int(os.environ.pop('TPROXY_FD'))
        try:
            sock = socket.fromfd(fd, family, socket.SOCK_STREAM)
        except socket.error, e:
            if e[0] == errno.ENOTCONN:
                log.error("TPROXY_FD should refer to an open socket.")
            else:
                raise
        bound = True
    else:
        sock = socket.socket(family, socket.SOCK_STREAM)

    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    
    for i in range(5):
        try:
            if not bound:
                sock.bind(address) 
            sock.setblocking(0)
            sock.listen(backlog)
            return sock
        except socket.error, e:
            if e[0] == errno.EADDRINUSE:
                log.error(str(address) % "Connection in use: %s")
            if e[0] == errno.EADDRNOTAVAIL:
                log.error("Invalid address: %s" % str(address))
                sys.exit(1)
            if i < 5:
                log.error("Retrying in 1 second. %s" % str(e))
                time.sleep(1)
dataset/ETHPy150Open benoitc/tproxy/tproxy/proxy.py/tcp_listener/swapped operands of `%`