英文:
Go ZMQ4 - Close a socket blocked on Recv?
问题
我正在使用这个库:https://github.com/pebbe/zmq4 来进行Go语言的ZeroMQ绑定。
我的问题是,如何安全地关闭一个正在等待消息的套接字?我在考虑为每个套接字创建一个新的上下文,然后我可以终止该上下文。
但是,pebbe/zmq4库似乎不允许我创建一个新的上下文。
谢谢你的帮助。
英文:
I am using this library: https://github.com/pebbe/zmq4 for Go bindings of ZeroMQ.
My question is, how do I safely close a socket that's waiting for a message? I was thinking of creating a new context for every socket and then I could just terminate the context.
But the pebbe/zmq4 library doesn't allow me to create a new context (or so it seems to me).
Thanks for helping.
答案1
得分: 0
我正在采纳我其中一位教授的简单而有效的建议。
在关闭时,我会向套接字发送一个独特的终止代码,并等待套接字读取并关闭自身。
英文:
I am going with a simple yet effective suggestion from one of my professors.
While closing, I send a unique termination code to the socket and wait till the socket reads it and closes itself.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论