|
Boost Users : |
Subject: Re: [Boost-users] Delimiting protocol messages (was [asio] read_some() splits data)
From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2011-05-12 14:17:40
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Marsh Ray
> Sent: May-12-11 1:11 PM
> To: boost_at_[hidden]; boost-users_at_[hidden]
> Subject: [Boost-users] Delimiting protocol messages (was [asio]
read_some()
> splits data)
>
> On 05/11/2011 09:36 AM, Andrew Holden wrote:
> > On Wednesday, May 11, 2011 9:57 AM, Slav wrote:
> >> Then messages of length not multiple of 128 (BUFFER_SIZE) will not be
> >> read - tested it, anyway, after last socket::read_some() (with
> >> readBytes> 0&& <
> >> BUFFER_SIZE) next socket::read_some() never ends.
> >
> > It would probably help to understand that TCP has no concept of a
> > "message". Anything you write to a socket is appended to a stream of
> > *bytes*.
>
> Alternatively, we could say that TCP, in fact, does have a well-defined
> concept of messages: they are all exactly one byte long.
>
Related to this, I wonder if there are any class libraries that facilitate
processing these byte streams.
I read, in the rationale part of the documentation for ASIO, the following:
"Basis for further abstraction. The library should permit the development of
other libraries that provide higher levels of abstraction. For example,
implementations of commonly used protocols such as HTTP."
It seems like such an obvious thing to do: to write a class library that
contains classes that use the TCP capabilities of boost::asio to
automagically take data read from the socket and do whatever is needed. For
example, one might want to construct a series of http requests from the data
coming in on port 443, and be able to relate the addressing data in the
application layer to that in the TCP layer, and use that comparison to
determine whether to forward the request to server A or server B. One
reason for doing so would be for, for example, my own edification (and
anyone else interested in learning) about how the different OSI layers work.
Another would be for security purposes (e.g. to know whether or not an
authorized user's session has been hijacked).
It seems to me to be an obvious thing to do, but my question to you is "Do
you know of anyone who has done it?" (in some kind of open source project)
If not, do you know of resources available online where I could learn how to
do it? I am finding it hard to find resources that are useful: I have well
developed C++ skills, e.g. to write custom IO stream classes, but need some
guidance on how to proceed with the 'further abstraction' the docs mention,
and what the recommended best practices are specific to (high performance,
secure) networking program development.
You said, " I've done a little protocol stuff with ASIO now and I must say
it's a lot of fun and I can't go back to doing it any other way." How did
you get started on it? Did you use any documentation other than the asio
docs? Do you know of any documents (ideally online) that show how you could
use this stuff to thwart the major kinds of attacks that can be made on a
web server?
Thanks
Ted
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net