Go to the documentation of this file.00001
00002
00003 import socket
00004 import struct
00005 import fcntl
00006 import array
00007
00008 import Receiver
00009
00010 class Datagram(Receiver.Datagram):
00011
00012 def __init__(self, source_address, source_port, target_address, target_port, ttl=32, loop=1):
00013 Receiver.Datagram.__init__(self, source_address, source_port)
00014
00015 self.ttl = ttl
00016 self.loop = loop
00017 self.target_address = target_address
00018 self.target_port = target_port
00019
00020 self.multicast = ord(socket.inet_aton(target_address)[0]) in range(224, 240)
00021
00022 if self.multicast:
00023 self._socket.setsockopt (socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, self.ttl)
00024 self._socket.setsockopt (socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, self.loop)
00025
00026 def write(self, data, *args):
00027 self._socket.sendto ( data, (self.target_address, self.target_port))