[zeromq-dev] Question about ROUTER queue (what if client dies)
Goswin von Brederlow
goswin-v-b at web.de
Tue Jul 29 13:47:46 CEST 2014
On Mon, Jul 28, 2014 at 02:42:50PM +0100, Pedro Januário wrote:
> hi Peter,
>
> I didn???t write C code for a while, but would be something like this:
>
> #include <czmq.h>
> int main (void)
> {
> zsock_t *router = zsock_new_router ("tcp://127.0.0.1:9990");
> zsock_t *dealer = zsock_new_dealer ("tcp://127.0.0.1:9990");
>
>
> // dealer send message
> zstr_send (dealer, "Hello World");
> // router received message
> zmsg_t *msg = zmsg_recv (router);
> zmsg_print (msg);
> // dealer (client) disconnects permanently
> zsock_destroy (&dealer);
> // router send message to dealer, because it thinks that is connected
> zmsg_send (&msg, router);
>
> zmsg_destroy (&msg);
> zsock_destroy (&router);
> return 0;
> }
>
> I hope this is self explanatory.
>
> One way to solve this, is by sending ???good bye??? message from dealer (client), but for my use case would be enough discharge message that are send after x minutes.
>
>
> Regards,
>
> Pedro Januário Delivering Innovation and Technology
That case is simple. The DEALER shuts down normally so the tcp socket
sends its FIN and the ROUTER removes the outgoing pipe.
But what if the DEALER deadlocks or the kernel crashes (asumming
different systems)? Then tcp will not close the connection for a long
time.
MfG
Goswin
More information about the zeromq-dev
mailing list