Skip to content

Instantly share code, notes, and snippets.

@mwcampbell
Created September 23, 2010 14:53
Show Gist options
  • Save mwcampbell/593737 to your computer and use it in GitHub Desktop.
Save mwcampbell/593737 to your computer and use it in GitHub Desktop.
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()
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