[asio] Address already in use / reuse_address
Hi list, I am having problems using asio. When I create a server (or take one of the examples from the website), start it and connect to it via telnet, then close the server (by closing all sockets, so io_service::run returns) and then want to restart the server again, I always get: "Address already in use." asio::error exception. I tried setting asio::ip::tcp::acceptor::reuse_address(true), but that didn't change anything. Any help/hint would be appreciated. Greetings, Max
Hi Max This is not a C++ answer but check if there is an instance of your program running an kill it. Sounds like the program is still running and it then occupies the port. So next time you run your program the port is already in use. Regards Stefan. On Wed, 2007-01-03 at 19:09 +0100, Maximilian Szengel wrote:
Hi list,
I am having problems using asio. When I create a server (or take one of the examples from the website), start it and connect to it via telnet, then close the server (by closing all sockets, so io_service::run returns) and then want to restart the server again, I always get: "Address already in use." asio::error exception. I tried setting asio::ip::tcp::acceptor::reuse_address(true), but that didn't change anything. Any help/hint would be appreciated.
Greetings,
Max _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users -- Stefan Kok
On 1/3/07, Stefan Kok
This is not a C++ answer but check if there is an instance of your program running an kill it. Sounds like the program is still running and it then occupies the port. So next time you run your program the port is already in use.
Actually, the socket needs to have the SO_REUSE_ADDR option set. I'm not sure how to do this properly w/ ASIO, so I'll defer to someone else. Jon
participants (3)
-
Jonathan Franklin
-
Maximilian Szengel
-
Stefan Kok