'sending an array in python using sockets

This is my python function:

  def handle(self):
        """
        The function handles the request
        :return: The function handles logging in.
        """

        str_db = open('db.json', 'r').read()
        json_db = json.loads(str_db)

        events_list = json_db['users'][self.username]['events']

        bytes_events_list = json.dumps(events_list).encode()

        self.sender_socket.send(bytes_events_list)

My question is - Can I send using sockets an array? 'events_list' contains a list of dictionaries. I'm turning it into bytes and then send it. Is it possible? because it doesn't work. If it's not possible. What are my other options? Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source