1

I have a program that runs fine on both Windows and MacOSX, but encounters the address already used problem on Linux (Fedora 23, to be specific). The issue turns out to be that I'm trying to construct two boost::asio::ip::tcp::acceptor objects on the same port, one for IPv4 and one for IPv6. The signature of the constructor used is as follows (see here):

basic_socket_acceptor(
    boost::asio::io_service & io_service,
    const endpoint_type & endpoint,
    bool reuse_addr = true);

Note the reuse_addr parameter. I expect it to address specifically the address already used problem. Alas, it does not work on Linux. Any explanation why?

Lingxi
  • 14,579
  • 2
  • 37
  • 93
  • @JohnZwinck Then, what is the use of `SO_REUSEADDR` on Linux, when you actually cannot reuse any address with it? – Lingxi Nov 10 '15 at 04:14
  • See http://stackoverflow.com/a/3233022/562566 –  Nov 10 '15 at 06:39
  • So it's not what you think. Also I'm not so sure that your question should have been closed as a duplicate, because I don't think your problem is really even anything to do with reuse address. Query the TCP table on your linux system and on windows. I bet you have some service bound to port 23 on your linux box. Unless writing for a specific protocol or you have other strong reasons, allow the system to assign your application a port by supplying 0 as an argument so the OS will fetch you an available ephemeral port. –  Nov 10 '15 at 06:44
  • I voted to reopen because your real question/problem is that you have boost-asio based software failing on linux. There's an issue not related to `reuse_addr`. I suggest editing your question so it's focus is on resolving your issue, not asking what gives about `reuse_addr`. Post an sscce while you're at it. –  Nov 10 '15 at 06:47
  • btw for querying, go to console, use variations of netstat like `netstat -ano`. –  Nov 10 '15 at 06:51

0 Answers0