Boost logo

Boost Users :

From: BRIDGES Dick (Dick.Bridges_at_[hidden])
Date: 2005-09-30 19:05:52


I created a server something like this:

handle_accept(){ do_the_right_thing(); }

Class Foo {
  socket_acceptor acceptor_;

Public:
  Foo(demuxer& d)
    : acceptor_( d, ipv4::tcp::endpoint(2525)){}

  Example(demuxer& d) {
    stream_socket* p = new stream_socket(d);
    acceptor_.async_accept(p, handle_accept);
  }
}

Everything works fine except when I (1) connect a client;
(2) ^C the server; (3) try to restart the server - which, as
expected, yields "Address already in use".

Mumbling something about defaulting modern socket libraries
to SO_REUSEADDR, I started trying to figure out where to call
set_option(stream_socket::reuse_address(true)) - and can't
work it out. I've set_option() on sockets and the acceptor
but can't make the acceptor reuse the address as long as the
connection that was established is still in TIME_WAIT. Do you
have an example that shows how this can be done?

Regards,
Dick Bridges


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net