BRIDGES Dick | 1 Oct 2005 02:05

[asio] init acceptor to reuse_address?

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,
(Continue reading)

Alan M. Carroll | 1 Oct 2005 02:31
Gravatar

Re: scoped_ptr help.

I initialize scoped_ptr in the member initialization list frequently. You should be able to do it as well.
However, I can't guess at what your problem is because

1) I don't know what error you are getting
2) I don't know what the constructor for CTest2 looks like

What I suspect is that you are passing the wrong argument to the initializer for m_spTest2. It should be
something like
        : m_spTest2(new CTest2(aa, bb))

Where you'd get instances for aa and bb from the default CTest construct is unclear, but that could the
actual problem.

Alternately, you would need to have CTest2 defined "near" the definition of the CTest() constructor,
because the CTest constructor invokes a method of CTest2. If defined outside the class, that would be
somewhere before the definition. If defined in CTest, then it could be as late as the closing brace of the
class (if CTest2 is a nested class).

At 06:04 PM 9/29/2005, you wrote:
>New to this topic,and need some help here.
>
>I have a class which use the scoped_ptr as a member variable.
>
>Class CTest
>{
>public:
>  CTest();
>  Initialize();
>  ~CTest();
>private:
(Continue reading)

me22 | 1 Oct 2005 08:43
Picon

Re: scoped_ptr help.

On 30/09/05, John Sun <jsunnewsgroup <at> gmail.com> wrote:
> Appreciate your help, can you explain what's the rationale that you use
> "reset" instead of a simple more natural way of "assign".
>

For one, that's the way that auto_ptr does it.

Second, plain assignment can cause hidden bugs because it would take
ownership of something in the middle where it's hard to notice.  You
can just construct a new smart pointer and assign the temporary to the
one you want to change, anyways.

- Scott
Peter Broadwell | 1 Oct 2005 09:39

nested vector<vector<int>> serialization help

I am new to Boost and am having no luck getting a nested vector
construct to serialize. Pretty sure I have the rigth includes, but
keep getting various errors out of g++ (sample below)

Anyone have some sample code that has the right set of magic in it.

Thanks -

;;peter

= = = start of a sample of the errors I get = = = = = =

g++  -I. -I /usr/kde/3.3/include -I /usr/qt/3/include -I
/usr/include/boost/test  `getconf LFS_CFLAGS`  -g -O2 -c testVec.cc
/usr/include/boost/archive/detail/oserializer.hpp: In function `void
boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = stashable_t]':
/usr/include/boost/archive/basic_text_oarchive.hpp:78:   instantiated
from
`voidboost::archive::basic_text_oarchive<Archive>::save_override(T&,
int) [with T = stashable_t, Archive = boost::archive::text_oarchive]'
/usr/include/boost/archive/detail/interface_oarchive.hpp:85:
instantiated from`Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = stashable_t, Archive = boost::archive::text_oarchive]'
genDigest.cc:209:   instantiated from here
/usr/include/boost/archive/detail/oserializer.hpp:566: error: incomplete
type `boost::STATIC_ASSERTION_FAILURE< false>' used in nested name specifier
/usr/include/boost/archive/detail/oserializer.hpp:566: error: size of
array has non-integral type `<type error>'
(Continue reading)

John Sun | 1 Oct 2005 15:19
Picon

Re: scoped_ptr help.

Alan M. Carroll wrote:
> I initialize scoped_ptr in the member initialization list frequently. You should be able to do it as well.
However, I can't guess at what your problem is because
> 
> 1) I don't know what error you are getting
> 2) I don't know what the constructor for CTest2 looks like
> 
> What I suspect is that you are passing the wrong argument to the initializer for m_spTest2. It should be
something like
>         : m_spTest2(new CTest2(aa, bb))
> 
> Where you'd get instances for aa and bb from the default CTest construct is unclear, but that could the
actual problem.
> 
[Yes, that's exactly where my problem comes from, because I cannot get 
the aa, bb from the CTest constructor, and it was passed in later on by 
the user of the class.]

> Alternately, you would need to have CTest2 defined "near" the definition of the CTest() constructor,
because the CTest constructor invokes a method of CTest2. If defined outside the class, that would be
somewhere before the definition. If defined in CTest, then it could be as late as the closing brace of the
class (if CTest2 is a nested class).
> 
> At 06:04 PM 9/29/2005, you wrote:
> 
>>New to this topic,and need some help here.
>>
>>I have a class which use the scoped_ptr as a member variable.
>>
>>Class CTest
(Continue reading)

Robert Ramey | 1 Oct 2005 15:24

Re: nested vector<vector<int>> serialization help

At the place where the error is encountered you will find the following 
comment:

// if your program traps here, it indicates taht your doing one of the 
following:

// a) serializing an object of a type marked "track_never" through a 
pointer.

// b) saving an non-const object of a type not markd "track_never)

// Either of these conditions may be an indicator of an error usage of the

// serialization library and should be double checked. See documentation on

// object tracking.

Robert Ramey

Peter Broadwell wrote:
> I am new to Boost and am having no luck getting a nested vector
> construct to serialize. Pretty sure I have the rigth includes, but
> keep getting various errors out of g++ (sample below)
>
> Anyone have some sample code that has the right set of magic in it.
>
> Thanks -
>
> ;;peter
>
(Continue reading)

George Sakkis | 1 Oct 2005 05:14
Picon
Favicon

Dynamic-only installation

Hi all,

I'd like to create a single version for each boost library instead of eight, so I run:
bjam  -sTOOLS=gcc -sBUILD="release <runtime-link>dynamic <threading>multi" install

Although it doesn't build the debug single-threaded versions, it still creates both the dynamic and
the static ones. Does the static version have to be built always ?

TIA,
George
Alan M. Carroll | 1 Oct 2005 18:22
Gravatar

Re: scoped_ptr help.

Then your possible solutions are:

1) Require aa,bb to be passed in to the CTest constructor.
2) Add a default constructor for CTest2 and a method to set the aa,bb at some later point.
3) Use scoped_ptr<T>::reset to put a CTest2 instance in the member when you get a valid aa,bb (as described
by other responders).

Personally, I'd go with (1) or (2) because otherwise you have to always check whether m_spTest2 is set or
not. I like to have my scoped_ptrs always pointing at something, or it's a error condition that needs to be
handled. In particular, (2) means that the knowledge of what to do if the CTest2 isn't valid is deferred to
CTest2, rather than being in CTest (i.e. less coupling). That's style, though, not an actual requirement
of the class.

At 08:19 AM 10/1/2005, you wrote:
>Alan M. Carroll wrote:
>> I initialize scoped_ptr in the member initialization list frequently. You should be able to do it as
well. However, I can't guess at what your problem is because
>> 
>> 1) I don't know what error you are getting
>> 2) I don't know what the constructor for CTest2 looks like
>> 
>> What I suspect is that you are passing the wrong argument to the initializer for m_spTest2. It should be
something like
>>         : m_spTest2(new CTest2(aa, bb))
>> 
>> Where you'd get instances for aa and bb from the default CTest construct is unclear, but that could the
actual problem.
>> 
>[Yes, that's exactly where my problem comes from, because I cannot get 
>the aa, bb from the CTest constructor, and it was passed in later on by 
(Continue reading)

Noel Belcourt | 1 Oct 2005 20:33
Picon

Re: [Boost][mpl] vector_c boolean operations


On Sep 29, 2005, at 7:45 PM, David Abrahams wrote:

> "Noel Belcourt" <kbelco <at> sandia.gov> writes:
>> r = p1 || p1 && p2
>
> That would be equivalent to r = p1.  Why go to all that trouble?  Or
> do you mean
>
>    r == p1 || p1 && p2

Yes, that's what I meant.

>
> Anyway, what does it mean to use the logical && operator on two
> sequences?  Do you want elementwise comparison?

Yes, element-wise comparison.

>  Do you want the same
> for r == p1?

Yes.

>   The usual meaning is to compare all elements and produce
> a scalar boolean, which would then be incompatible with the vector of
> bools produced by p1 && p2.  Maybe you mean something like;
>
>       mpl::transform<
>           mpl::transform<r,p1,mpl::equal_to<_,_> >::type
(Continue reading)

David Abrahams | 2 Oct 2005 02:47
Picon
Picon
Favicon
Gravatar

Re: Managing builds

Caleb Epstein <caleb.epstein <at> gmail.com> writes:

> On 9/28/05, Aaron Griffin <aaronmgriffin <at> gmail.com> wrote:
>
>> Subject: feature wish for boost 1.32.1 or 1.33.0: pkg-config support
>> > http://thread.gmane.org/gmane.comp.lib.boost.devel/115215
>> >
>> > Subject: [boost.build] RFE: pkg-config
>> > http://thread.gmane.org/gmane.comp.lib.boost.devel/126039
>>
>> Thanks. I did come across similar discussions before, but still don't
>> know if there are any results. Does anyone know if anything came from
>> the discussions above?
>
>
>
> I don't believe either discussion reached anything resembling closure. Part
> of the problem (at least my take on it) seems to be communicating the
> utility of pkg-config (or something like it) to the Boost.Build-centriccrowd.

More likely the problem is that someone who knows and understands
pkg-config hasn't contributed support for it to Boost.

--

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Gmane