Networking made simply using nng
Maintained. Last release 2 weeks ago, commits in 6 of the last 26 weeks. Weaker on contributor spread and security practices.
pip install pynngThis is pynng.
Ergonomic bindings for nanomsg next generation (nng), in Python. pynng provides a nice interface on top of the full power of nng. nng, and therefore pynng, make it easy to communicate between processes on a single computer or computers across a network. This library is compatible with Python ≥ 3.6. nng is the rewriting of Nanomsg, which is the spiritual successor to ZeroMQ.
Goals
Provide a Pythonic, works-out-of-the box library on Windows and Unix-y platforms. Like nng itself, the license is MIT, so it can be used without restriction.
Installation
On Windows, MacOS, and Linux, the usual
pip3 install pynng
should suffice. Note that on 32-bit Linux and on macOS no binary distributions are available, so CMake is also required.
Building from the GitHub repo works as well, natch:
git clone https://github.com/codypiersall/pynng
cd pynng
pip3 install -e .
(If you want to run tests, you also need to pip3 install trio curio pytest pytest-asyncio pytest-trio pytest-curio,
then just run pytest test.)
pynng might work on the BSDs as well. Who knows!
Using pynng
Using pynng is easy peasy:
from pynng import Pair0
s1 = Pair0()
s1.listen('tcp://127.0.0.1:54321')
s2 = Pair0()
s2.dial('tcp://127.0.0.1:54321')
s1.send(b'Well hello there')
print(s2.recv())
s1.close()
s2.close()