In that case, you probably have to close the acceptor as soon as one
connection is made, and then open it again when the connection is
closed. In other words, there is probably code in there that looks
something like:
boost::asio::ip::tcp::acceptor m_acceptor(m_io_service);
m_acceptor.open(endpoint.protocol());
m_acceptor.bind(endpoint);
m_acceptor.listen(backlog);
m_acceptor.async_accept(m_socket, boost::bind(&Server::HandleAccept,
this, boost::asio::placeholders::error));
In your HandleAccept, you need to call:
boost::system::error_code ec;
m_acceptor.close(ec);
And then restart the whole thing (open, bind, listen, async_accept)
after the connection is closed.
Post by Robert BielikTried that, i.e. only accepting the socket if zero connections are active, and upon the disconnect call async_accept), but still I have no problem using putty to connect to the server, with several instances. Granted, there is no "connection" with the server, but I'd like putty to just fail directly with an error.
So that doesn't work, it seems...
Regards
/R
-----Original Message-----
Sent: den 23 juli 2017 18:36
Subject: Re: [asio-users] Accept one connection only
that's what should happen if you call async_accept once, then don't call it
again until (a) after a connection is made and closed; or (b) the async_accept
handler is called with an error
Post by Robert BielikI'm using the TCP server example (with acceptor. async_accept), but I'd like
to modify it so that only a single connection should be possible. All other
connection attempts should result in an error. What need I do ?
Post by Robert BielikRegards
/Robert
----------------------------------------------------------------------
-------- Check out the vibrant tech community on one of the world's
most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging
tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio