~landscape/twisted/14.0.2-1ubuntu1

« back to all changes in this revision

Viewing changes to doc/_downloads/echoserv.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-07-14 13:53:15 UTC
  • mfrom: (1.3.2) (44.2.3 sid)
  • Revision ID: package-import@ubuntu.com-20140714135315-z2f6727ypy31nldq
Tags: 14.0.0-1ubuntu1
* Merge with Debian; remaining changes:
  - Keep the preliminary python3 support, but don't enable it.
  - Try to use plain pygtkcompat and fall back to gi.pygtkcompat, to
    avoid a DeprecationWarning, and a crash.
  - Use new io_add_watch api on new versions of pygobject.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Copyright (c) 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()