从zmq.error.ZMQError中恢复:地址已在使用中 [英] Recovering from zmq.error.ZMQError: Address already in use

查看:969
本文介绍了从zmq.error.ZMQError中恢复:地址已在使用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与ZMQ运行PAIR模式(非阻塞客户端服务器)连接时,我按了Ctrl-C.稍后,当我尝试运行REQ-REP(阻止客户端单服务器连接)模式时,我总是收到Address already in use错误.我尝试用netstat -ltnp | grep :<my port>运行netstat,但是没有列出任何进程.

I hit Ctrl-C while running a PAIR pattern (non-blocking client servers) connection with ZMQ. Later when I tried running the REQ-REP (blocking client single server connection) pattern, I keep getting the Address already in use error. I have tried running netstat with netstat -ltnp | grep :<my port> but that does not list any process.

那到底是谁在使用这个地址?

So who exactly is using this address?

还有一个如何优雅地关闭此类套接字连接?

Also how does one gracefully shutdown socket connections like these?

推荐答案

问题1:

如果执行sudo netstat -ltnp,则在Linux类型的操作系统上,您很可能会看到拥有该端口的进程.用kill -9 <pid>杀死它.

If you do sudo netstat -ltnp, on a Linux type operating system, you will most probably see the process owning the port. Kill it with kill -9 <pid>.

问题2:

退出程序时,关闭套接字,然后调用zmq_ctx_destroy().这破坏了上下文.有关更多信息,请参见 http://zguide.zeromq.org/page:all#toc17

When you exit the program, close your sockets and then call zmq_ctx_destroy(). This destroys the context. See http://zguide.zeromq.org/page:all#toc17 for more info.

这篇关于从zmq.error.ZMQError中恢复:地址已在使用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆