~0x44/nova/config-drive

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/examples/echoserv.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
#!/usr/bin/env python
 
2
 
 
3
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
 
4
# See LICENSE for details.
 
5
 
 
6
from twisted.internet.protocol import Protocol, Factory
 
7
from twisted.internet import reactor
 
8
 
 
9
### Protocol Implementation
 
10
 
 
11
# This is just about the simplest possible protocol
 
12
class Echo(Protocol):
 
13
    def dataReceived(self, data):
 
14
        """
 
15
        As soon as any data is received, write it back.
 
16
        """
 
17
        self.transport.write(data)
 
18
 
 
19
 
 
20
def main():
 
21
    f = Factory()
 
22
    f.protocol = Echo
 
23
    reactor.listenTCP(8000, f)
 
24
    reactor.run()
 
25
 
 
26
if __name__ == '__main__':
 
27
    main()