Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Z
zeromq-examples
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kei Tsuji
zeromq-examples
Commits
759f9b6e
Commit
759f9b6e
authored
Feb 14, 2023
by
Kei Tsuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pub-sub example
parent
06b4e37d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
publisher.py
pub-sub/publisher.py
+5
-2
subscriber.py
pub-sub/subscriber.py
+1
-0
No files found.
pub-sub/publisher.py
View file @
759f9b6e
...
...
@@ -9,7 +9,10 @@ context = zmq.Context()
socket
=
context
.
socket
(
zmq
.
PUB
)
socket
.
bind
(
'tcp://*:5555'
)
for
i
in
range
(
5
):
socket
.
send
(
b
'status 5'
)
for
i
in
range
(
5000
):
# socket.send(b'status 5')
# socket.send(b'statuses')
s
=
f
'status {i}'
socket
.
send
(
s
.
encode
(
'ascii'
))
socket
.
send
(
b
'All is well'
)
time
.
sleep
(
1
)
pub-sub/subscriber.py
View file @
759f9b6e
...
...
@@ -9,6 +9,7 @@ context = zmq.Context()
socket
=
context
.
socket
(
zmq
.
SUB
)
socket
.
connect
(
'tcp://localhost:5555'
)
socket
.
setsockopt
(
zmq
.
SUBSCRIBE
,
b
'status'
)
# socket.setsockopt(zmq.SUBSCRIBE, b'')
while
True
:
message
=
socket
.
recv_multipart
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment