~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/pair/examples/pairudp.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from twisted.internet import reactor, protocol
 
2
from twisted.pair import ethernet, rawudp, ip
 
3
from twisted.pair import tuntap
 
4
 
 
5
class MyProto(protocol.DatagramProtocol):
 
6
    def datagramReceived(self, *a, **kw):
 
7
        print a, kw
 
8
 
 
9
p_udp = rawudp.RawUDPProtocol()
 
10
p_udp.addProto(42, MyProto())
 
11
p_ip = ip.IPProtocol()
 
12
p_ip.addProto(17, p_udp)
 
13
p_eth = ethernet.EthernetProtocol()
 
14
p_eth.addProto(0x800, p_ip)
 
15
 
 
16
reactor.listenWith(tuntap.TuntapPort,
 
17
                   interface='tap0', proto=p_eth, reactor=reactor)
 
18
reactor.run()