|
Revision 30752, 1.2 KB
(checked in by exarkun, 15 months ago)
|
|
Rewrite the copyright headers to exclude date information.
Author: exarkun
Reviewer: glyph
Fixes: #4857
To avoid the need to perpetually update copyright dates in each file in Twisted,
remove the dates from most files and just leave them in the LICENSE file.
As a side effect, some files also have had a trailing newline added where it was
missing before.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | # Copyright (c) Twisted Matrix Laboratories. |
|---|
| 4 | # See LICENSE for details. |
|---|
| 5 | |
|---|
| 6 | from OpenSSL import SSL |
|---|
| 7 | import sys |
|---|
| 8 | |
|---|
| 9 | from twisted.internet.protocol import ClientFactory |
|---|
| 10 | from twisted.protocols.basic import LineReceiver |
|---|
| 11 | from twisted.internet import ssl, reactor |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | class EchoClient(LineReceiver): |
|---|
| 15 | end="Bye-bye!" |
|---|
| 16 | def connectionMade(self): |
|---|
| 17 | self.sendLine("Hello, world!") |
|---|
| 18 | self.sendLine("What a fine day it is.") |
|---|
| 19 | self.sendLine(self.end) |
|---|
| 20 | |
|---|
| 21 | def connectionLost(self, reason): |
|---|
| 22 | print 'connection lost (protocol)' |
|---|
| 23 | |
|---|
| 24 | def lineReceived(self, line): |
|---|
| 25 | print "receive:", line |
|---|
| 26 | if line==self.end: |
|---|
| 27 | self.transport.loseConnection() |
|---|
| 28 | |
|---|
| 29 | class EchoClientFactory(ClientFactory): |
|---|
| 30 | protocol = EchoClient |
|---|
| 31 | |
|---|
| 32 | def clientConnectionFailed(self, connector, reason): |
|---|
| 33 | print 'connection failed:', reason.getErrorMessage() |
|---|
| 34 | reactor.stop() |
|---|
| 35 | |
|---|
| 36 | def clientConnectionLost(self, connector, reason): |
|---|
| 37 | print 'connection lost:', reason.getErrorMessage() |
|---|
| 38 | reactor.stop() |
|---|
| 39 | |
|---|
| 40 | def main(): |
|---|
| 41 | factory = EchoClientFactory() |
|---|
| 42 | reactor.connectSSL('localhost', 8000, factory, ssl.ClientContextFactory()) |
|---|
| 43 | reactor.run() |
|---|
| 44 | |
|---|
| 45 | if __name__ == '__main__': |
|---|
| 46 | main() |
|---|