Re: [Boost-users] [ASIO] async_accept : Error m_val 1.

I've made unit test for this problem.
Server.h:
#pragma once
#include
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. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Thu, 10 Mar 2011 13:47:46 +0100, Cyprien DIOT
I've made unit test for this problem.
Server.h:
#pragma once
#include
#include #include #include <iostream> class Server { public: AssistGui(boost::asio::io_service &); ~AssistGui(void);
void accept(const boost::system::error_code& e); void sendMsg(const char *msg, unsigned int size);
private: boost::asio::io_service &io; boost::asio::ip::tcp::socket _client; boost::asio::ip::tcp::acceptor _acceptor;
};
Server.cpp:
#include "Server.h"
using boost::asio::ip::tcp;
Server::Server(boost::asio::io_service &ios) : io(ios), _client(ios), _acceptor(ios, tcp::endpoint(tcp::v4(), 14242)) { _acceptor.async_accept(_client, boost::bind(&Server::accept, this, boost::asio::placeholders::error)); }
void Server::sendMsg(const char *msg, unsigned int size) {
} Server::~Server(void) { }
void Server::accept(const boost::system::error_code& e) { // same error :-( : "Already open" }
int main() { boost::asio::io_service ios;
Server s(ios); ios.run(); }
The error is still the same "Already open". _WIN32_WINNT=0x0501 is defined. I tried to change port. No warnings at program compilation. Can you help me?
Thank you
Cyprien DIOT
Hi Cyprien, as far as I remember from socket programming, if you open a socket without REUSE option, it is marked busy even after releasing for a some time afterwards depending on your kernel implementation. Probably if you reboot or wait some time, your testcase will work but again only once. Try setting REUSE flag for your socket to check if it helps. -- Slava
participants (2)
-
Cyprien DIOT
-
Viatcheslav.Sysoltsev@h-d-gmbh.de