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?
No, there's no method in the API to check if a socket is connected. ZeroMq abstracts the network; client and server connections are completely transparent to the peer making the connection.
ZeroMQ (also spelled ØMQ, 0MQ or ZMQ) is an asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker; the zero in the name is for zero broker.
ZMQ. Context Context is an object serving as a container for all the sockets of a single process. By creating a new context, you start one or more input/output threads: DEFINE context ZMQ.Context. Associated methods: socket()
ZeroMQ is an asynchronous network messaging library known for its high performance. It's intended use is for distributed systems as well as concurrent systems.
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.
reboot
start using try:
/ except:
/ finally:
encapsulation constructors, that will help you to grant a graceful exit from all zmq allocations, incl. all Socket-s' .close()
and Context's .term()
without any hanging orphan(s) an memory leak(s), even in case any panic button or unhandled exception interrupts your code-execution altogether with losing references to your still hanging, network-hardware bound, instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With