Skip to content

Commit 5a84998

Browse files
authored
Merge pull request #1737 from Adrien-Luxey/master
clarified the 'Networking with Trio' section of the tutorial
2 parents aca5cc2 + e021029 commit 5a84998

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

docs/source/tutorial.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -836,19 +836,25 @@ Networking with Trio
836836
Now let's take what we've learned and use it to do some I/O, which is
837837
where async/await really shines.
838838

839-
840-
An echo client
841-
~~~~~~~~~~~~~~
842-
843-
The traditional application for demonstrating network APIs is an "echo
844-
server": a program that accepts arbitrary data from a client, and then
845-
sends that same data right back. (Probably a more relevant example
839+
The traditional toy application for demonstrating network APIs is an
840+
"echo server": a program that awaits arbitrary data from remote clients,
841+
and then sends that same data right back. (Probably a more relevant example
846842
these days would be an application that does lots of concurrent HTTP
847843
requests, but for that `you need an HTTP library
848844
<https://github.com/python-trio/trio/issues/236#issuecomment-310784001>`__
849845
such as `asks <https://asks.readthedocs.io>`__, so we'll stick
850846
with the echo server tradition.)
851847

848+
In this tutorial, we present both ends of the pipe: the client, and the
849+
server. The client periodically sends data to the server, and displays its
850+
answers. The server awaits connections; when a client connects, it recopies
851+
the received data back on the pipe.
852+
853+
854+
An echo client
855+
~~~~~~~~~~~~~~
856+
857+
852858
To start with, here's an example echo *client*, i.e., the program that
853859
will send some data at our echo server and get responses back:
854860

@@ -857,6 +863,9 @@ will send some data at our echo server and get responses back:
857863
.. literalinclude:: tutorial/echo-client.py
858864
:linenos:
859865

866+
Note that this code will not work without a TCP server such as the one
867+
we'll implement below.
868+
860869
The overall structure here should be familiar, because it's just like
861870
our :ref:`last example <tutorial-example-tasks-intro>`: we have a
862871
parent task, which spawns two child tasks to do the actual work, and

0 commit comments

Comments
 (0)