import socket


def create_socket(host, port):
    """
    Creates TCP socket and starts listening

    host: host to bind to
    port: port to bind to
    """
    addr = (
        host,
        port,
    )
    if socket.has_dualstack_ipv6():
        gemsocket = socket.create_server(
            addr, family=socket.AF_INET6, dualstack_ipv6=True
        )
    else:
        gemsocket = socket.create_server(addr)
    gemsocket.listen()
    return gemsocket