[Twisted-Python] udp broadcast question
Gaspard, Bradley S
BRADLEY.S.GASPARD at saic.com
Tue Oct 24 16:55:45 EDT 2006
It does work when I specify the broadcast address of my wireless interface.
I am still
curious if one can specify on which interface to broadcast to
255.255.255.255 ... perhaps
not a twisted question.
-----Original Message-----
From: twisted-python-bounces at twistedmatrix.com on behalf of Gaspard, Bradley
S
Sent: Tue 10/24/2006 4:27 PM
To: twisted-python at twistedmatrix.com
Subject: [Twisted-Python] udp broadcast question
I found a udp broadcast example (below) which works fine for my wired
ethernet interface but I would like to be able to specify my wireless
interface (ath0) for the udp broadcast. How can this be done?
On Wednesday, Dec 17, 2003, at 17:27 Europe/Helsinki, Jp Calderone
wrote:
>
> No threads, but maybe it's good enough anyway:
Thanks for trying to help. But really this is very incomplete, missing
all read or write calls to the socket.
And I've tried, with just that SO_BROADCAST option I do not receive the
stuff I send, and in fact with just that option, I can't even send.
But thanks for the pointer to twisted.
Torsten
> import sys
> from socket import SOL_SOCKET, SO_BROADCAST
>
> from twisted.internet import reactor
> from twisted.internet import protocol
> from twisted.internet import task
> from twisted.python import log
>
> log.startLogging(sys.stdout)
>
> port = 7154
>
> class BroadcastingDatagramProtocol(protocol.DatagramProtocol):
>
> port = port
>
> def startProtocol(self):
> self.transport.socket.setsockopt(SOL_SOCKET, SO_BROADCAST,
> True)
> self.call = task.LoopingCall(self.tick)
> self.dcall = self.call.start(1.0)
>
> def stopProtocol(self):
> self.call.stop()
>
> def tick(self):
> self.transport.write(self.getPacket(), ("<broadcast>",
> self.port))
>
> def getPacket(self):
> return "Some bytes for you"
>
> def datagramReceived(self, data, addr):
> print "Received", repr(data)
>
> reactor.listenUDP(port, BroadcastingDatagramProtocol())
> reactor.run()
>
> Jp
>
> --
> http://mail.python.org/mailman/listinfo/python-list
_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3688 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20061024/e9c36096/attachment.bin
More information about the Twisted-Python
mailing list