为什么 ZeroMQ 演示代码在 Win10 上不起作用?
Why a ZeroMQ demo code doesn't work on Win10?
我正在学习如何从 client/trader 的角度与服务器通信。看起来 ZeroMQ 是处理这个问题的首选包。我在网站上找到了这段演示代码。问题是它不会像 post: Why a ZeroMQ example does not work? 那样产生所需的输出。
每当我尝试 运行 代码时,它都会冻结,并且什么也没有出来。
我什至无法在上面的 post 中发表评论并提出我的问题,因为我的信用不够好。
为了您的信息,我尝试 运行 Windows 10 台计算机上的代码。
我相信我已经更改了防火墙上 TCP 连接的入站和出站设置,我读到这是需要使用 Win-10 完成的设置。我还想也许我应该将目录的写入方式从“//
”更改为“\
”。也没用。此外,我尝试将本地 tcp 更改为“tcp://127.0.0.1:5555
”,但仍然没有。
这是代码,
import time
import zmq
context = zmq.Context()
socket=context.socket(zmq.REP)
socket.bind("tcp://*:5555")
while True:
message=socket.recv()
print("Received request: %s" % message)
time.sleep(1)
print("test")
socket.send(b"World")
import zmq
context = zmq.Context()
print("Connecting to hello world server...")
socket = context.socket(zmq.REQ)
socket.connect("tcp://*:5555")
for request in range(10):
print("Sending request %s..." % request)
socket.send(b"Hello")
message = socket.recv()
print("Received reply %s [%s]" % (request, message))
如有任何建议,我们将不胜感激。
如果你从未使用过 ZeroMQ,
你可能会喜欢先看看
,然后再深入了解更多细节
Q : "Why a ZeroMQ demo code doesn't work on Win10?"
因为这个 SLOC :
socket.connect( "tcp://*:5555" ) # production-grade code always ERROR checks a call
这个调用应该指定一个 tcp://
-TransportClass 一个有效的 address:port
去尝试 .connect()
,它必须失败上面的帖子尝试 "*:port
"
修复它,你应该准备好进入美丽的零之禅花园了。
我正在学习如何从 client/trader 的角度与服务器通信。看起来 ZeroMQ 是处理这个问题的首选包。我在网站上找到了这段演示代码。问题是它不会像 post: Why a ZeroMQ example does not work? 那样产生所需的输出。
每当我尝试 运行 代码时,它都会冻结,并且什么也没有出来。 我什至无法在上面的 post 中发表评论并提出我的问题,因为我的信用不够好。
为了您的信息,我尝试 运行 Windows 10 台计算机上的代码。
我相信我已经更改了防火墙上 TCP 连接的入站和出站设置,我读到这是需要使用 Win-10 完成的设置。我还想也许我应该将目录的写入方式从“//
”更改为“\
”。也没用。此外,我尝试将本地 tcp 更改为“tcp://127.0.0.1:5555
”,但仍然没有。
这是代码,
import time
import zmq
context = zmq.Context()
socket=context.socket(zmq.REP)
socket.bind("tcp://*:5555")
while True:
message=socket.recv()
print("Received request: %s" % message)
time.sleep(1)
print("test")
socket.send(b"World")
import zmq
context = zmq.Context()
print("Connecting to hello world server...")
socket = context.socket(zmq.REQ)
socket.connect("tcp://*:5555")
for request in range(10):
print("Sending request %s..." % request)
socket.send(b"Hello")
message = socket.recv()
print("Received reply %s [%s]" % (request, message))
如有任何建议,我们将不胜感激。
如果你从未使用过 ZeroMQ,
你可能会喜欢先看看
,然后再深入了解更多细节
Q : "Why a ZeroMQ demo code doesn't work on Win10?"
因为这个 SLOC :
socket.connect( "tcp://*:5555" ) # production-grade code always ERROR checks a call
这个调用应该指定一个 tcp://
-TransportClass 一个有效的 address:port
去尝试 .connect()
,它必须失败上面的帖子尝试 "*:port
"
修复它,你应该准备好进入美丽的零之禅花园了。