Subject: [Boost-bugs] [Boost C++ Libraries] #3900: Request for support of "release" member function or assign without ownership transfer to asio socket
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-04 15:42:16
#3900: Request for support of "release" member function or assign without
ownership transfer to asio socket
---------------------------------+------------------------------------------
Reporter: artyomtnk@⦠| Owner: chris_kohlhoff
Type: Feature Requests | Status: new
Milestone: Boost 1.43.0 | Component: asio
Version: Boost 1.42.0 | Severity: Problem
Keywords: |
---------------------------------+------------------------------------------
boost::asio socket has assign member function allowing to transfer native
socket to the asio socket. However, there is no option to release such
handler or assign without ownership transfer.
Please add one of these options.
Rationale: null_buffer allow easy integration of 3rd part libraries to
ASIO main loop for reactor style operations. However, today it is
impossible to use it with 3rd part libraries that do not transfer on the
socket ownership.
Let's assume I have 3rd part library that gives me a file descriptor to
put it in select loop for asynchronous operations.
If I assign file descriptor to the socket, I would not be able to destroy
socket object because it would close the connection.
and I accidentally may close other valid socket.
{{{
Thread A
--------
foo f=foo_open() // fd=4
sock.assign(foo_native(f));
...
foo_close(f); // fd = 4 closed
Thread B
---------
some_fd = open() // some_fd = 4
Thread A
--------
~sock() /// fd=4 closed!!!! thread B can't work
}}}
Can you please provide one (or both) of the following APIs:
{{{
// Transfer socket ownership to user and reset socket object.
native_type release();
// Attach an existing native socket to the socket
// (assign do not transfer ownership)
void attach(const protocol_type & protocol,
const native_type & native_socket);
boost::system::error_code attach(
const protocol_type & protocol,
const native_type & native_socket,
boost::system::error_code & ec);
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3900> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC