Last active
February 22, 2023 07:05
Revisions
-
Dansyuqri revised this gist
Mar 8, 2020 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,5 @@ # Subscribes to all topics socket.subscribe("ML") # Receives a multipart message print(socket.recv_multipart()) -
Dansyuqri created this gist
Mar 8, 2020 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ # multipart_pub.py import zmq import time host = "127.0.0.1" port = "5001" # Creates a socket instance context = zmq.Context() socket = context.socket(zmq.PUB) # Binds the socket to a predefined port on localhost socket.bind("tcp://{}:{}".format(host, port)) time.sleep(1) # Sends a multipart message socket.send_multipart([b"ML", b"hello"]) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ # multipart_sub.py import zmq host = "127.0.0.1" port = "5001" # Creates a socket instance context = zmq.Context() socket = context.socket(zmq.SUB) # Connects to a bound socket socket.connect("tcp://{}:{}".format(host, port)) # Subscribes to all topics socket.subscribe("ML") # Receives a string format message print(socket.recv_multipart())