Re: how to handle multiple-message-in-same data-buffer (async programming)



On Mar 18, 6:00 pm, "Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx>
wrote:
On Tue, 18 Mar 2008 14:31:13 -0700, <asha...@xxxxxxxxxx> wrote:
[...]
There is 'content-length' field in the data that i get, but not sure
how to go-about handling both (or multiple) messages.

What do you mean by "content-length" field? Does that reliably describe
the actual bytes that are sent? If so, then you'll want to get that
value, and then use it to determine how many bytes are to be included in
the current message. Use only that many bytes, and save the remaining
bytes to be used later.

Without more specific information from you (for example, what is actually
being sent), it's hard to offer any specific advice. The fundamental
issue is that you need to know how many bytes constitute a single message,
and process only those bytes when processing that single message.

Pete

In async programming model, if two messages are received exactly at
the same time by the server, how does it handle it? (is it on separate
threads?).

Yes, there is a content-length field that accurately describes the #
of bytes in the message (similar to a http-post that will have header-
fields consisting of content-length and other fields, and then body
consisting of the message).
I can write a program/method to check if there is more than 1 instance
of content-length and then filter/process accordingly. But isnt there
a more better way to handle scenarios where-in two messages are
received in the same buffer?

Thanks.
RS
.