-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
Ping Demo | ||
========= | ||
|
||
Copy the code below into a file called ``ping.py``. | ||
Install dependencies, preferably in a virtual environment, with: | ||
This example demonstrates how to use the libp2p ``ping`` protocol. | ||
|
||
.. code-block:: bash | ||
.. code-block:: console | ||
python -m pip install libp2p | ||
$ python -m pip install libp2p | ||
Collecting libp2p | ||
... | ||
Successfully installed libp2p-x.x.x | ||
$ ping-demo | ||
Run this from the same folder in another console: | ||
Run the demo with ``python ping.py`` and copy the output. | ||
ping-demo -p 8001 -d /ip4/127.0.0.1/tcp/8000/p2p/QmXfptdHU6hqG95JswxYVUH4bphcK8y18mhFcgUQFe6fCN | ||
Open a second terminal, navigate to the folder that contains ``ping.py``, then paste | ||
and run the copied line. | ||
Waiting for incoming connection... | ||
Copy the line that starts with ``ping-demo -p 8001``, open a new terminal in the same | ||
folder and paste it in: | ||
|
||
.. code-block:: console | ||
$ ping-demo -p 8001 -d /ip4/127.0.0.1/tcp/8000/p2p/QmXfptdHU6hqG95JswxYVUH4bphcK8y18mhFcgUQFe6fCN | ||
sending ping to QmXfptdHU6hqG95JswxYVUH4bphcK8y18mhFcgUQFe6fCN | ||
received pong from QmXfptdHU6hqG95JswxYVUH4bphcK8y18mhFcgUQFe6fCN | ||
The full source code for this example is below: | ||
.. literalinclude:: ../examples/echo/echo.py | ||
:language: python | ||
:linenos: |