[zeromq-dev] cleaning up TCP sockets

Joel Lauener Joel.Lauener at cern.ch
Thu Mar 21 11:34:03 CET 2013


Currently we are developing a transport library for a TCP based client-server distributed system. We use the DEALER-ROUTER combo to connect our client to our servers (the relation is n to n). We also have an heartbeat system so both client and server can detect if the peer is not communicating.

My question is regarding the clean-up of the TCP sockets when a peer is blocked (not when the peer process dies, this works fine).

When, through heartbeat, the client detects that a server is not responding I close the corresponding DEALER socket. This in turns should close the underlying TCP socket. Is this assumption correct? If so we have no problem there.

However on the server side it is a different story. Currently we have a single ROUTER that is connected to all the client. If the server detects that a client is not responding I clean-up our connection object but do nothing with the ROUTER socket. So the TCP socket stays alive as long as the client doesn't exit or until it actively closes its socket. Is this correct? I'm afraid that this could be a potential problem in production if several clients got stuck and they pile up.

With ZeroMQ, is there a (relatively not hackish) way to force closing of a low-level TCP socket? We have a Java and a C++ implementation, they both must behave the same.

Thanks for reading!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130321/4afc21ae/attachment.htm>

More information about the zeromq-dev mailing list