I have a acceptor
server which listens to various connections from clients. It creates one server
object per client connection. I need the clients to connect to only one IP port
of the server. Following the examples in boost I do this:
(sample code)
boost::asio::ip::tcp::acceptor m_acceptor;
boost::asio::ip::tcp::resolver resolver(iosvr);
boost::asio::ip::tcp::resolver::query query(host.c_str(),boost::lexical_cast<std::string>(port));
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
m_acceptor.open(endpoint.protocol());
m_acceptor.set_option(boost::asio::socket_base::reuse_address(true));
if( bNoDelay )
m_acceptor.set_option(boost::asio::ip::tcp::no_delay(true));
else
m_acceptor.set_option(boost::asio::ip::tcp::no_delay(false));
m_acceptor.bind(endpoint);
m_acceptor.listen();
At runtime the server listens to one and only
one client connection, the others are not connected at all.
What is wrong in the
implementation? OR How do I make acceptor to accept multiple connections on the
same server port?
Any help is highly
appreciated.