human
Complete this python program:
def get_socket(default_port):
assistant
#Here is the Python program you requested.

    """Bind socket to bind ip:port in conf
    note: Mostly comes from Swift with a few small changes...
    :param default_port: port to bind to if none is specified in conf
    :returns : a socket object as returned from socket.listen or
    ssl.wrap_socket if conf specifies cert_file
    """
    bind_addr = get_bind_addr(default_port)
    address_family = [addr[0] for addr in socket.getaddrinfo(bind_addr[0], bind_addr[1], socket.AF_UNSPEC, socket.SOCK_STREAM) if (addr[0] in (socket.AF_INET, socket.AF_INET6))][0]
    cert_file = CONF.cert_file
    key_file = CONF.key_file
    use_ssl = (cert_file or key_file)
    if (use_ssl and ((not cert_file) or (not key_file))):
        raise RuntimeError(_('When    running    server    in    SSL    mode,    you    must    specify    both    a    cert_file    and    key_file    option    value    in    your    configuration    file'))
    def wrap_ssl(sock):
        ssl_kwargs = {'server_side': True, 'certfile': cert_file, 'keyfile': key_file, 'cert_reqs': ssl.CERT_NONE}
        if CONF.ca_file:
            ssl_kwargs['ca_certs'] = CONF.ca_file
            ssl_kwargs['cert_reqs'] = ssl.CERT_REQUIRED
        return ssl.wrap_socket(sock, **ssl_kwargs)
    sock = None
    retry_until = (time.time() + 30)
    while ((not sock) and (time.time() < retry_until)):
        try:
            sock = eventlet.listen(bind_addr, backlog=CONF.backlog, family=address_family)
            if use_ssl:
                sock = wrap_ssl(sock)
        except socket.error as err:
            if (err.args[0] != errno.EADDRINUSE):
                raise
            eventlet.sleep(0.1)
    if (not sock):
        raise RuntimeError((_('Could    not    bind    to    %s:%s    after    trying    for    30    seconds') % bind_addr))
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
    if hasattr(socket, 'TCP_KEEPIDLE'):
        sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, CONF.tcp_keepidle)
    return sock