[asio] obtaining a socket descriptor from ip::tcp::socket
Hello, I would like to incorporate asio into my current project. However, I am restricted by a library that uses C-style socket descriptors to identify sockets, e.g. it contains functions similar to void foo(int fd, ...) Right now, I picture write an asio server that merely performs an asynchronous accept. Thereafter, the start() function in handle_accept() (see below) would invoke calls to the library such as foo(fd, ...) and spawn a dedicated thread per client that would gather data from the socket. void Server::handle_accept(const boost::system::error_code& e) { if (! e) { new_connection_->start(); new_connection_.reset(new Connection(...) //... In this example, asio would only be used to to handle the accept() and provide an outside interface to the rest of the application while the actual read()/write() calls are capsulated in the library. Is there a way to obtain a native socket descriptor from an ip::tcp::socket object? I am aware that mixing asio with C-style networking code totally breaks platform independence and it is generally a very ugly approach. On the other side, the C-style library would be capsulated behind one asio Server object, without interacting with the remaining application code. I appreciate any input on this issue, Matthias -- Matthias Vallentin vallentin@icsi.berkeley.edu pgp/gpg: 0x37F34C16
Is there a way to obtain a native socket descriptor from an> ip::tcp::socket object?
Yes, http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/reference/basic_str... _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
On Apr 23, 2008, at 3:44 PM, Igor R. wrote:
Yes, http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/reference/basic_str...
Thanks, I was looking for that. Matthias -- Matthias Vallentin vallentin@icsi.berkeley.edu pgp/gpg: 0x37F34C16
participants (2)
-
Igor R.
-
Matthias Vallentin