def send_datagram(self, message, address, message_type="<STR_LIT>"):
if self.bufsize is not <NUM_LIT:0> and len(message) > self.bufsize:<EOL><INDENT>raise Exception("<STR_LIT>" +<EOL>"<STR_LIT>" + str(self.bufsize) + "<STR_LIT>")<EOL><DEDENT>if message_type == "<STR_LIT>":<EOL><INDENT>self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, <NUM_LIT:1>)<EOL><DEDENT>elif message_type == "<STR_LIT>":<EOL><INDENT>self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, <NUM_LIT:2>)<EOL><DEDENT>try:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>self.sock.sendto(message, address)<EOL>if self.stats_enabled:<EOL><INDENT>self.stats['<STR_LIT>'] += len(message)<EOL><DEDENT><DEDENT>except socket.error:<EOL><INDENT>logger.error("<STR_LIT>")<EOL><DEDENT>
Sends a UDP datagram packet to the requested address.

        Datagrams can be sent as a "unicast", "multicast", or "broadcast"
        message. Unicast messages are messages that will be sent to a single
        host, multicast messages will be delivered to all hosts listening for
        multicast messages, and broadcast messages will be delivered to ALL
        hosts on the network.

        Args:
          message (str): The raw serialized packet data to send.
          address (tuple): The address and port of the destination to send the
            packet. E.g. (address, port)
          message_type -- The type of packet to send. Can be "unicast",
            "multicast", or "broadcast". Defaults to "unicast".

        Returns:
          None