-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Movable ssl::stream #124
Comments
[EDITED] I'm thinking about writing this wrapper: ...
|
[EDITED] @2underscores-vic This compiles, but is untested:
|
Yes, I would use the same workaround - allocation on heap, but in my project I'm trying to minimize heap allocations, so it's used only on highest levels of abstraction. BTW, move operations can be easily added to |
Have you looked at the implementation of
I don't know. You might look at the declaration for You're proposing changing the source code to Boost.Asio. That might work for your application but its not really a good solution to force everyone who wants to use some piece of code to modify their installation of Boost. |
No, I use standalone Asio 1.11. And why others have to modify their code if they don't/can't use moving today? |
Sorry, I meant
|
I can't add a feature to Beast (my HTTP library) that requires users to modify their Asio sources. |
I don't understand how this feature request to Asio relates to Beast or any other library... |
This feature request has been open for almost two years? I am using beast library and the immovability of the ssl::stream makes it super hard to pass a stream that has a handshake initiated on it into other classes. For example: handshare a stream in http class and hand it off to websocket class. Any update on the progress would be much appreciated. |
This is already a solved problem, the Beast "advanced server" examples implement WebSocket upgrade handoff of the ssl stream from the HTTP request to the WebSocket handler. A movable version of Advanced server examples may be found here: |
Hey @vinniefalco thanks for sharing. I went through that code example with a fine comb. Really cool example. I ended up refactoring the code and using the ssl_stream but instead of all the generics and separate classes I used only two classes (Http, Websocket) and used boost::variant to pass both plain and secured sockets around. |
It's nice that we have a working example emulating a proper, movable ssl::stream. It is still confusing for developers though - you have to really search for how to do this instead of it "just" working. Reading the comments on this issue, the only reason it seems we don't have movable streams is that the buffers are made const. I think the added value we get from those members being const in no way outweighs the benefits of having movable streams. I would really like to hear @chriskohlhoff take on this. If he offers no objections, I'd consider making a PR to fix this once and for all. |
Beast offers an Beast's This will become an "official" interface in an upcoming Boost release, but it can be relied upon today. Also note that Boost.Beast 1.70 will ship
To get a stream with these features:
In-development version of |
did you propose this to asio? if not, why not. I mean: great for the workaround!! but seems a bit messy to have to do this, especially since they are both boost libraries. |
What would be the difference between being in beast or being in asio? |
Visibility. When you think about "how do I sent something over this TCP socket with a timeout", the most logical place to look for something like this is asio. You won't find it there and might conclude you have to write it all on your own. The things you write here are very useful. It'd be a shame if people don't use them because they don't find them. |
or in the original case for which this ticket was opened if the ssl stream in asio where to be made movable then users of asio, and also would directly pick up the movable streams and have less head aches. also they would not have to depend on beast to use it. |
beast's |
How so? |
Resolved in 658614d? |
Oh, this looks very promising indeed! @vinniefalco Would you take a PR that switches out the I guess to be properly compatible with standalone asio (which might have an older version) we could simply make a type trait that checks whether or not |
The latest Asio makes |
No.
|
Is there any reason why
ssl::stream
is still not movable? As far as I can see, the feature was requested 2 years ago here https://svn.boost.org/trac/boost/ticket/9724The text was updated successfully, but these errors were encountered: