File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # publisher
2+
3+ import trzmq
4+ import trio
5+ import zmq
6+
7+ async def run ():
8+ context = zmq .Context ()
9+ socket = context .socket (zmq .PUB )
10+ socket .connect ("tcp://0.0.0.0:5556" )
11+
12+ s = trzmq .Socket (socket )
13+ i = 1
14+ while True :
15+ topic = b"ZMQ-Test"
16+ message = "Hello, NORM " + str (i ) + "..."
17+ await s .send (b"%b %b" % (topic , message .encode ()))
18+ print ("%s %s" % (topic , message ))
19+ i += 1
20+ await trio .sleep (1 )
21+
22+ trio .run (run )
Original file line number Diff line number Diff line change 1+ pyzmq
2+ trio
Original file line number Diff line number Diff line change 1+ # subscriber
2+
3+ import trio
4+ import trzmq
5+ import zmq
6+
7+ async def run ():
8+ context = zmq .Context ()
9+ socket = context .socket (zmq .SUB )
10+ socket .bind ("tcp://0.0.0.0:5556" )
11+ socket .setsockopt_string (zmq .SUBSCRIBE , '' )
12+ s = trzmq .Socket (socket )
13+ while True :
14+ string = await s .recv ()
15+ print (string )
16+
17+ trio .run (run )
Original file line number Diff line number Diff line change 55
66from ._proxy import *
77__all__ += _proxy .__all__
8+
9+ from ._socket import *
10+ __all__ += _socket .__all__
You can’t perform that action at this time.
0 commit comments