Last active
November 21, 2018 16:20
-
-
Save JoseKilo/319493e6ef3f17d86a76ad7c7b20055e to your computer and use it in GitHub Desktop.
Basic aiozmq sender-receiver
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 | |
import itertools | |
import aiozmq | |
import zmq | |
async def main(): | |
router = await aiozmq.create_zmq_stream(zmq.ROUTER, bind="tcp://127.0.0.1:5555") | |
for i in itertools.count(): | |
ident, data = await router.read() | |
print("Received", i) | |
# router.write((ident, b"")) | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |
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 | |
import itertools | |
import aiozmq | |
import zmq | |
async def main(): | |
dealer = await aiozmq.create_zmq_stream(zmq.DEALER) | |
dealer.transport.setsockopt(zmq.IDENTITY, b"1234") | |
await dealer.transport.connect("tcp://127.0.0.1:5555") | |
for i in itertools.count(): | |
print("Sending", i) | |
dealer.write([b""]) | |
# await dealer.read() | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment