Skip to content

Commit

Permalink
readme: added network connector example
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarshall108 committed Oct 17, 2017
1 parent bf0e850 commit 61adc5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ A simple tcp server example
factory = network.NetworkFactory('0.0.0.0', 8080, ExampleHandler)
factory.run()
A simple tcp connection example

.. code:: python
from curionet import network
class ExampleConnector(network.NetworkConnector):
"""
An example connector derived from NetworkConnector
"""
async def handle_connected(self):
print ('Connected.')
async def handle_received(self, data):
print ('Data recieved from server (%s: %r)!' % (self.address, data))
async def handle_disconnected(self):
print ('Disconnected.')
if __name__ == '__main__':
connector = ExampleConnector('127.0.0.1', 8080)
connector.run()
Other Resources
---------------

Expand Down
2 changes: 1 addition & 1 deletion tests/tests_tcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def handle_connected(self):
await self.handle_send('Hello World!')

async def handle_received(self, data):
print ('Data recieved from (%s: %r)!' % (self.address, data))
print ('Data recieved from server (%s: %r)!' % (self.address, data))

async def handle_disconnected(self):
print ('Disconnected.')
Expand Down

0 comments on commit 61adc5d

Please sign in to comment.