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?
Question 1:
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>
.
Question 2:
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.