Created
September 23, 2010 14:53
-
-
Save mwcampbell/593737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet.protocol import Protocol, ClientCreator | |
from twisted.internet import reactor | |
class TestProtocol(Protocol): | |
def connectionMade(self): | |
self.transport.write("1234" * 1048576) | |
self.transport.loseConnection() | |
def connectionLost(self, reason): | |
reactor.stop() | |
ClientCreator(reactor, TestProtocol).connectTCP("localhost", 4321) | |
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import iocpreactor | |
iocpreactor.install() | |
from twisted.internet.protocol import Protocol, Factory | |
from twisted.internet import reactor | |
class TestProtocol(Protocol): | |
total = 0 | |
def dataReceived(self, data): | |
self.total += len(data) | |
def connectionLost(self, reason): | |
print self.total | |
class TestFactory(Factory): | |
protocol = TestProtocol | |
reactor.listenTCP(4321, TestFactory()) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment