> Does the line in the specification "messages will not necessarily be
> completed in order" mean that the actual client (not the BLIP
> implementation) can receive message B before message A in:
Yes, although only in the case of long messages that get broken into chunks (4k by default) and interleaved during transmission. For example, if one peer sends a 16k message A and an 8k message B, the chunks will probably be sent in this order:
A1 B1 A2 B2 A3 A4
then the other peer will receive the complete B before the complete A, so the current implementation would deliver B to the delegate first.
—Jens
Thanks.
Fahad
Sent from my iPhone
> Hmmm. So the application might receive B (which was intended to arrive after A first).
The current implementation doesn’t really have a notion of queueing messages one at a time. Instead, all messages that have been posted by the sender are available to be delivered. This works well when you have several different agents or subsystems on the two sides that want to communicate independently of each other, since none of them can block the others by sending huge messages, but not for a protocol that’s more linear.
The network protocol definitely supports this, it’s just something that would need to be added to the implementation and API
> Doe the application then need to create an internal queue and manage delivery of messages itself? That sounds like a pretty complex thing to achieve and should really be hidden away by BLIP's implementation instead I would have thought.
When receiving a message you can look at the message’s number. If you haven’t already received the message whose number is one less, push the message onto a queue. Otherwise, handle the message, then handle and remove the first message in the queue as long as its message number is one greater.
Another way would be to have the sender wait for a reply to its latest message before it sends the next one (but this decreases throughput.)
> Any idea how the application could be relieved of the burden of managing the delivery order itself?
Well, what you want is something like the ‘channel’ mechanism of BEEP (the protocol that inspired BLIP). Messages within the same channel are sent one at a time in order, though interleaved with messages from other channels. When I designed BLIP my goal was to make it a lot simpler; I knew channels were one of the more complicated parts of BEEP, and I didn’t need them for my own app.
Another way might be to add a notification when a message has been completely sent. Then the app could keep a queue of outgoing messages and not tell the BLIPConnection to send the next one until the previous one was finished. [I think the BLIPMessage.complete flag could be repurposed for this — currently it’s only used in incoming messages, to remember whether the complete message has arrived, but it could also be used in outgoing ones to tell when the complete message was sent.) The nice thing about this is that the queuing behavior could be implemented as an optional class, like BLIPRequestQueue, without complicating the existing code.
—Jens
Thanks
Sent from my iPhone