我试图通过IPC实现PUB / SUB。如果我更改了下面的代码,以便订阅者绑定到“tcp:// *:5000”,并且发布者连接到“tcp:// localhost:5000”,它就可以工作,但是我无法通过IPC工作。我究竟做错了什么?
subscriber.py
import zmq, json
def main():
context = zmq.Context()
subscriber = context.socket(zmq.SUB)
subscriber.bind("ipc://test")
subscriber.setsockopt(zmq.SUBSCRIBE, '')
while True:
print subscriber.recv()
if __name__ == "__main__":
main()
publisher.py
import zmq, json, time
def main():
context = zmq.Context()
publisher = context.socket(zmq.PUB)
publisher.connect("ipc://test")
while True: