Last active
May 25, 2017 08:22
-
-
Save Enforcer/5629c71b4c1cb225873bfd1a459e78d4 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
import asyncio | |
class EchoClientProtocol(asyncio.Protocol): | |
def __init__(self, message, loop): | |
self.message = message | |
self.loop = loop | |
def connection_made(self, transport): | |
transport.write(self.message.encode()) | |
print('Data sent: {!r}'.format(self.message)) | |
def data_received(self, data): | |
print('Data received: {!r}'.format(data.decode())) | |
def connection_lost(self, exc): | |
print('The server closed the connection') | |
print('Stop the event loop') | |
self.loop.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment