You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with a somewhat complex system and trying to re-write one subsystem to use ASIO without rewriting other subsystem, yet. The subsystem under re-write does not open connections: that is handled by a separate connection pooling subsystem. This is no problem when constructing a stream_socket, because of the stream socket constructor that consumes a native_handle_type, so I can just use the descriptor that I get back from the pool subsystem.
However, after the re-written subsystem has completed its activity, it is expected to hand back the still open socket to the pooling subsystem. This requires that I sever the connection between the stream_socket object and the native handle, so that when the stream_socket object is destroyed, the handle remains valid.
I cannot see a way to accomplish this in ASIO as of the ASIO 1-11-0 API. The ability to temporarily and non-destructively associate existing sockets with ASIO types would make it much easier to incrementally integrate ASIO with existing network libraries while migrating fully to ASIO.
Apologies if I have overlooked a mechanism for doing this in the existing code.
The text was updated successfully, but these errors were encountered:
@chriskohlhoff FYI I'd be happy to write a PR for this feature if you are supportive of it. If not (or, worse, if I've missed some obvious existing way to sever the connection between a basic_socket and the underlying native handle), please let me know so I can start working on a different strategy.
This is not supported because it cannot be portably implemented. Specifically, on Windows a socket is associated to an I/O completion port and cannot be disassociated.
If you are only targeting POSIX-based systems then perhaps you can stick the descriptor into a posix::stream_descriptor instead? This class does provide a release() member function.
@chriskohlhoff I see... that makes sense. I will need to support Windows, so it looks like I will need to find another approach. I appreciate you taking the time to explain.
I'm working with a somewhat complex system and trying to re-write one subsystem to use ASIO without rewriting other subsystem, yet. The subsystem under re-write does not open connections: that is handled by a separate connection pooling subsystem. This is no problem when constructing a stream_socket, because of the stream socket constructor that consumes a native_handle_type, so I can just use the descriptor that I get back from the pool subsystem.
However, after the re-written subsystem has completed its activity, it is expected to hand back the still open socket to the pooling subsystem. This requires that I sever the connection between the stream_socket object and the native handle, so that when the stream_socket object is destroyed, the handle remains valid.
I cannot see a way to accomplish this in ASIO as of the ASIO 1-11-0 API. The ability to temporarily and non-destructively associate existing sockets with ASIO types would make it much easier to incrementally integrate ASIO with existing network libraries while migrating fully to ASIO.
Apologies if I have overlooked a mechanism for doing this in the existing code.
The text was updated successfully, but these errors were encountered: