Hi,
about this topic I would have two questions. The scenario is simple: 1 sender and 1 receiver sharing a boost message queue.
Q1: If the sender removes the queue by the function remove("myQueue") how can the receiver to be aware the queue no longer exists? In my implementation the receiver uses the function
timed_receive(...) and if the sender removes the queue the function returns false, since timeout is reached. The problem, in my case, is that the receiver cannot tell if the queue has been deleted or the sender is not sending messages anymore.
Q2: I experience a different behavior of the receiver depending on the language, C or C++.
Actually I created two receivers: recv.c and recv.cpp. The sender is written in C++.
The operations sequence is the following:
Sender:
- creates the queue "myQueue"
- writes some messages
- removes the queue
- terminates
Receiver:
- loops reading message on the queue "myQueue", applying timeout
Sender:
- restarts
- creates the queue "myQueue"
- ...
When the sender terminates, the receiver keeps to try reading. The queue has been removed, so the
timed_receive(…) function goes in timeout.
When I restart the sender, the C++ receiver properly resumes reading the messages . With the C version, instead, the receiver is not able to resume and the receive function keeps going in timeout. Why the C++ version resumes while the C
doesn't?
If the sender terminates leaving the queue as it is and then restarts, the C receiver resumes properly.
Unfortunately the implementation requires that if the sender has to terminate for any reason, the queue must be removed.
I hope I've been clear enough.
Thank you very much.