gpt4 book ai didi

python-2.7 - zmq.error.ZMQError : No such device

转载 作者:行者123 更新时间:2023-12-02 08:28:47 32 4
gpt4 key购买 nike

我在我的程序中遇到了这个错误:

Traceback (most recent call last):
File "scriptA.py", line 17, in <module>
socketPub.bind("tcp://localhost:%s"% portPub)
File "socket.pyx", line 434, in zmq.backend.cython.socket.Socket.bind (zmq/backend/cython/socket.c:3928)
File "checkrc.pxd", line 21, in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:6058)
zmq.error.ZMQError: No such device

这是我为重现它所做的一个简单脚本:
import zmq
import random
import sys
import time

port = "5566"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)

portSub = "5556"
context = zmq.Context()

portPub = "5566"
#contextPub = zmq.Context()
socketPub = context.socket(zmq.PUB)
socketPub.bind("tcp://localhost:%s"% portPub)

socket = context.socket(zmq.SUB)
socket.connect("tcp://localhost:%s"% portSub)
socket.setsockopt(zmq.SUBSCRIBE,'')


while True:
socket.send("BB", zmq.SNDMORE)
socket.send("16", zmq.SNDMORE)
socket.send("14", zmq.SNDMORE)
socket.send("11", zmq.SNDMORE)
socket.send("4")
time.sleep(3)

我想订阅一个点并能够发送到另一个点。是否可以? 2个不同的终点。 A发送给B,B发送给C。

最佳答案

尝试用 localhost 替换 127.0.0.1

有关更多信息,请查看此 stackoverflow thread

关于python-2.7 - zmq.error.ZMQError : No such device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29437565/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com