~cbehrens/nova/lp844160-build-works-with-zones

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/examples/simpleserv.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
 
 
2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
 
 
6
from twisted.internet import reactor, protocol
 
7
 
 
8
 
 
9
class Echo(protocol.Protocol):
 
10
    """This is just about the simplest possible protocol"""
 
11
    
 
12
    def dataReceived(self, data):
 
13
        "As soon as any data is received, write it back."
 
14
        self.transport.write(data)
 
15
 
 
16
 
 
17
def main():
 
18
    """This runs the protocol on port 8000"""
 
19
    factory = protocol.ServerFactory()
 
20
    factory.protocol = Echo
 
21
    reactor.listenTCP(8000,factory)
 
22
    reactor.run()
 
23
 
 
24
# this only runs if the module was *not* imported
 
25
if __name__ == '__main__':
 
26
    main()