Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: third_party/twisted_8_1/twisted/protocols/wire.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """Implement standard (and unused) TCP protocols.
5
6 These protocols are either provided by inetd, or are not provided at all.
7 """
8
9 # system imports
10 import time, struct
11 from zope.interface import implements
12
13 # twisted import
14 from twisted.internet import protocol, interfaces
15
16
17 class Echo(protocol.Protocol):
18 """As soon as any data is received, write it back (RFC 862)"""
19
20 def dataReceived(self, data):
21 self.transport.write(data)
22
23
24 class Discard(protocol.Protocol):
25 """Discard any received data (RFC 863)"""
26
27 def dataReceived(self, data):
28 # I'm ignoring you, nyah-nyah
29 pass
30
31
32 class Chargen(protocol.Protocol):
33 """Generate repeating noise (RFC 864)"""
34 noise = r'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !" #$%&?'
35
36 implements(interfaces.IProducer)
37
38 def connectionMade(self):
39 self.transport.registerProducer(self, 0)
40
41 def resumeProducing(self):
42 self.transport.write(self.noise)
43
44 def pauseProducing(self):
45 pass
46
47 def stopProducing(self):
48 pass
49
50
51 class QOTD(protocol.Protocol):
52 """Return a quote of the day (RFC 865)"""
53
54 def connectionMade(self):
55 self.transport.write(self.getQuote())
56 self.transport.loseConnection()
57
58 def getQuote(self):
59 """Return a quote. May be overrriden in subclasses."""
60 return "An apple a day keeps the doctor away.\r\n"
61
62 class Who(protocol.Protocol):
63 """Return list of active users (RFC 866)"""
64
65 def connectionMade(self):
66 self.transport.write(self.getUsers())
67 self.transport.loseConnection()
68
69 def getUsers(self):
70 """Return active users. Override in subclasses."""
71 return "root\r\n"
72
73
74 class Daytime(protocol.Protocol):
75 """Send back the daytime in ASCII form (RFC 867)"""
76
77 def connectionMade(self):
78 self.transport.write(time.asctime(time.gmtime(time.time())) + '\r\n')
79 self.transport.loseConnection()
80
81
82 class Time(protocol.Protocol):
83 """Send back the time in machine readable form (RFC 868)"""
84
85 def connectionMade(self):
86 # is this correct only for 32-bit machines?
87 result = struct.pack("!i", int(time.time()))
88 self.transport.write(result)
89 self.transport.loseConnection()
90
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/protocols/toc.py ('k') | third_party/twisted_8_1/twisted/protocols/xmlstream.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698