Created
December 4, 2017 19:06
-
-
Save markrwilliams/e592203ae8315544504d0efc100dc1db to your computer and use it in GitHub Desktop.
This file contains hidden or 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 endpoints, defer, protocol, task | |
class Echo(protocol.Protocol): | |
def dataReceived(self, data): | |
self.transport.write(data) | |
@task.react | |
def main(reactor): | |
listening = endpoints.TCP4ServerEndpoint( | |
reactor, 9999).listen(protocol.Factory.forProtocol(Echo)) | |
@listening.addCallback | |
def forever(_): | |
return defer.Deferred() | |
return listening |
Author
markrwilliams
commented
Dec 4, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment