On Wed, Feb 15, 2012 at 12:28 PM, Dorin Ciobanu (dciobanu)
<dciob...@cisco.com> wrote:
> Hi!
>
>
>
> My application uses a session oriented design.  I have a PULL socket in a
> client app and a PUSH socket in a server app. Sometimes my client app goes
> away, and I do not know a way to detect this in my server, so I keep sending
> messages into the PUSH socket (using non-blocking flag).
>
> When client application starts, it asks for the queue address from the
> server app (using a non-ZMQ mechanism). At that moment, I do something to
> close the old session and initialize a new session, then tell the client the
> address to connect to for pulling messages.
>
> Unfortunately, my client app gets a few “old” messages before getting new
> ones.
>
>
>
> What is the best solution for this? Is there a way to “clear the cache” on
> the socket? Or is there a way to detect a client is no longer connected?
>
> I would like to avoid close/bind because it’s a multi-user machine (windows)
> with concurrent processes that quite actively take and release TCP ports. I
> could end up with the port occupied by competition and that leads to a whole
> list of things I have to take care about.
>

Hello,

without knowing more about the application here are some options that
come into mind:

1. If you can rely on clocks on the client and the server you could
timestamp the messages and expire them on the client side if the
delivery has taken too long. This would effectively allow you to not
process the messages even though they are delivered.

2. Use HWM [1] to limit amount of messages that get pushed into the
pipe. For example setting HWM to very low value you should get EAGAIN
if the client is not there to receive them.

3. Use a different socket type, such as PUB/SUB where the HWM action
is to drop the messages [2]. This is more of a radio broadcast model
(which you seem to be after) where messages are delivered to everyone
listening and when clients tune off they won't get the messages.

Thanks,
Mikko

[1] http://api.zeromq.org/2-1:zmq-setsockopt#toc3
[2] http://api.zeromq.org/2-1:zmq-socket#toc9 (HWM action)
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to