Start New Discussion within our Software Development Community
Server::Server(boost::asio::io_service& io_service,std::string ip,short port,std::shared_ptr<ConnectionFactory> factory)
	: acceptor_(io_service, boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string(, port)){

		m_factory = factory;

		std::cout<<"Socket accepting connections..."<<std::endl;


void Server::start_accept(){
	boost::asio::io_service io_service;
	std::shared_ptr<Connection> conn = m_factory->create(io_service);

		boost::bind(&Server::handle_accept, this,conn,

void Server::handle_accept(std::shared_ptr<Connection> conn,const boost::system::error_code& error){

    if (!error)
		std::cout<<"on connected"<<std::endl;

when i run the project i got

Unhandled exception at 0x00c55c8c in AccountServer.exe: 0xC0000005: Access violation reading location 0xfeeeff02.

and the call stack here


AccountServer.exe!boost::asio::detail::win_iocp_io_service::register_handle(void * handle, boost::system::error_code & ec)  Line 135 + 0x9 bytes	C++

so what's wrong here?!!

I've just started playing with boost and have implemented both the async server and client sides. One thing that I see wrong is the declaration of io_service inside of start_accept(). The io_service must exist outside start_accept so that you can eventually call and actually perform the accept().

This article has been dead for over six months. Start a new discussion instead.