Boost logo

Boost :

From: BRIDGES Dick (Dick.Bridges_at_[hidden])
Date: 2005-10-04 12:20:48


Hi Chris.

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of
> Christopher Kohlhoff
> Sent: Monday, October 03, 2005 3:01 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [asio] init acceptor to reuse_address?
>
>
> Hi Dick,
>
> --- BRIDGES Dick <Dick.Bridges_at_[hidden]> wrote:
[snip]
> > Mumbling something about defaulting modern socket libraries
> > to SO_REUSEADDR,
>
> Do you think I should change the default to set SO_REUSEADDR to true?
> At the moment I leave all options to default to whatever the OS
> provides. Is there a good reason why all OSes (that I know of) have it
> default to false I wonder? Or is it just historical?
 
No. SO_REUSEADDR does increase the attack surface. Not a lot and less
now than in the past but IMHO there's no point in helping the bad guys
even a little bit if it's not required. Besides, I doubt all that many
people would find it useful. My mumbling was aimed more toward myself
than anything else - I have written a fair amount of "server" code and
should have developed better habits by now. ;)

[snip]
>
> asio::ipv4::tcp::endpoint endpoint(port);
> acceptor_.open(endpoint.protocol());
> acceptor_.set_option(asio::socket_acceptor::reuse_address(true));
> acceptor_.bind(endpoint);
> acceptor_.listen();
> acceptor_.async_accept(new_connection_->socket(),
> boost::bind(&server::handle_accept, this,
> asio::placeholders::error));
>
> (From the new http example I've written:
> http://cvs.sourceforge.net/viewcvs.py/asio/asio/src/examples/
> http/server/server.cpp?rev=1.1&view=markup).

Hmmm. The copy of the library I downloaded on 14 September doesn't
have socket_acceptor::reuse_address and linux.softpedia.com says the
last update was 5 September. I used stream_socket::reuse_address
instead and that worked. Is there a newer version of the library
somewhere else?

Other than that one substitution, this fixed the problem.

I would like to see this initialization code pushed back down into
the acceptor. Maybe something along the lines of an "option_policy",
but I can't come up with anything to suggest that isn't more trouble
than it's worth.

Thanks - *AGAIN* - for the help.

Regards,
Dick


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk