
Hello, I'm currently developping a tcp server with boost asio with vs2010 on win 7. My server class: Header file: class Server { private: boost::asio::io_service &_io; boost::asio::ip::tcp::acceptor *acceptor; bool connected; boost::asio::ip::tcp::socket *_client; }; Source file: Server::Server(boost::asio::io_service& io) : _io(io) { connected = false; } void Server::receiving() { boost::system::error_code error; acceptor = new tcp::acceptor(_io, tcp::endpoint(tcp::v4(), 14242)); _client = new tcp::socket(_io); connected = false; try { acceptor->async_accept(*_client, boost::bind(&Server::handle_accept, this, boost::asio::placeholders::error)); } catch(...) { } } void Server::handle_accept(const boost::system::error_code& error) { // problem appears here } In main function, i'm running io.run(); I'm using in another class boost asio as a tcp client (which work properly) with the same io_service. When a tcp client connect to boost asio tcp server (Class Server), handle_accept is called. error has the following values: m_val = 1; m_cat = 0x00ab8d00 instance; | [boost::asio::error::detail::misc_category] = {...} | boost::noncopyable_::noncopyable = {...} | __vfptr = 0x00a8bf18 const boost::asio::error::detail::misc_category::`vftable' | [0] = 0x0098aaaa boost::asio::error::detail::misc_category::`scalar deleting destructor'(unsigned int) | [1] = 0x0098b4e1 boost::asio::error::detail::misc_category::name(void) | [2] = 0x0098b603 boost::asio::error::detail::misc_category::message(int) | [3] = 0x0098e39e boost::system::error_category::default_error_condition(int) | [4] = 0x0098bef0 boost::system::error_category::equivalent(class boost::system::error_code const &,int) | [5] = 0x0098cb61 boost::system::error_category::equivalent(int,class boost::system::error_condition const &) Do anyone know what does it mean? Can you help me to fix it? Thank you ! Cyprien DIOT France

m_val = 1; m_cat = 0x00ab8d00 instance; | [boost::asio::error::detail::misc_category] = {...} | boost::noncopyable_::noncopyable = {...} | __vfptr = 0x00a8bf18 const boost::asio::error::detail::misc_category::`vftable'
Use message() member function of error_code to see the error description. IIUC, in your case it should be "Already open", i.e. you're trying to accept new connection to a socket which was already open.
participants (2)
-
Cyprien DIOT
-
Igor R