
Hi, I am trying to clone a socket from process to another, mostly for having one process per client in a network server. Some legacy stuff makes this the only design possible, so the threaded approach is simply not feasible... Anyway, when I'm trying to create a boost socket from a cloned WSA socket I get an exception. class boost::exception_detail::clone_impl< struct boost::exception_detail::error_info_injector< class boost::system::system_error >
: The parameter is incorrect
This same happens for this example program, using boost 1.37 Does anyone have an idea why this does not work? #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include <windows.h> #include <winsock2.h> #pragma comment(lib, "ws2_32") #include <boost/asio.hpp> namespace ip = boost::asio::ip; int main_impl(int argc, char* argv[]) { boost::asio::io_service ios; ip::tcp::socket s(ios); ip::tcp::acceptor a(ios, ip::tcp::endpoint(ip::tcp::v4(), 1777)); a.accept(s); WSAPROTOCOL_INFO info; if (WSADuplicateSocket(s.native(), GetCurrentProcessId(), &info)) { std::cerr << "WSAError: " << WSAGetLastError() << std::endl; return EXIT_FAILURE; } // pass info over a pipe to the client... SOCKET copy(WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO , FROM_PROTOCOL_INFO, &info, NULL, NULL)); ip::tcp::socket scopy(ios, ip::tcp::v4(), copy); return EXIT_SUCCESS; } int main(int argc, char* argv[]) { try { return main_impl(argc, argv); } catch(std::exception const& ex) { std::cerr << typeid(ex).name() << ":" << ex.what() << std::endl; return EXIT_FAILURE; } } -- Eld på åren og sol på eng gjer mannen fegen og fjåg. [Jøtul] <demo> 2009 Tore Halvorsen || +052 0553034554