id summary reporter owner description type status milestone component version severity resolution keywords cc 5157 Assign native socket problem a.pacek@… chris_kohlhoff "Hi I'm trying to duplicate accepted/opened socket and pass them to other process. It works fine under linux. But under Windows I can't assign this native socket to boost::asio::ip::tcp::socket. When I try to assign opened native socket to boost socket object s.assign(boost::asio::ip::tcp::v4(), socketDup) throws me exception: ""The parameter is incorrect"". Even if I try to duplicate socket and use them in the same process. I still got this exception. The line inside boost throws this exception: boost_1_45_0\boost\asio\detail\impl\win_iocp_io_service.ipp: {{{ boost::system::error_code win_iocp_io_service::register_handle( HANDLE handle, boost::system::error_code& ec) { if (::CreateIoCompletionPort(handle, iocp_.handle, 0, 0) == 0) //this function failed { DWORD last_error = ::GetLastError(); ec = boost::system::error_code(last_error, boost::asio::error::get_system_category()); } else { ec = boost::system::error_code(); } return ec; } }}} I'm using: VC++ 2008 / Win7 What am I doing wrong? How can I resolve this problem? Thanks for help. Example code: {{{ boost::asio::io_service io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), m_nPort)); std::cout << ""Waiting for connection..."" << std::endl; tcp::socket socket(io_service); acceptor.accept(socket); std::cout << ""connection accepted"" << std::endl; #ifdef _WIN32 WSAPROTOCOL_INFO pi; WSADuplicateSocket(socket.native(), get_current_process_id(), &pi); SOCKET socketDup = WSASocket(pi.iAddressFamily/*AF_INET*/, pi.iSocketType/*SOCK_STREAM*/, pi.iProtocol/*IPPROTO_TCP*/, &pi, 0, 0); char sText[] = ""I can use my duplicated socket via WinApi!\r\n""; int nRet = send(socketDup, sText, strlen(sText), 0); #else //linux int socketDup = dup(socket.native()); #endif try { tcp::socket s(io_service); s.assign(boost::asio::ip::tcp::v4(), socketDup); //this throws exception under Windows //I can't use my socket via boost lib s.send(boost::asio::buffer(""Not work\r\n"")); } catch(std::exception &e) { std::cerr << e.what() << std::endl; //""The parameter is incorrect"" exception } }}} " Bugs new asio Boost 1.45.0 Problem native socket assign