Boost Users :
Subject: Re: [Boost-users] [asio] reopening of serial port fails - why?
From: Bill Somerville (bill_at_[hidden])
Date: 2009-03-06 06:47:02
Markus Werle wrote:
> Markus Werle <numerical.simulation <at> web.de> writes:
>> while (true) // PROBLEM: reentering this loop fails - why?
>> boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));
>> Now the reconnection does not succeed either and
>> after some tries I obtain an invalid file handle error.
>> I guess I am missing some fundamental thing with asio ...
> ... or maybe it is some bug.
> Any further comment?
I think you should simplify your close semantics, passing an error code
to your do_close() method is making it do more work than necessary.
I don't understand the recreation of the serial_port object although I
have not used the serial_port functionality myself. Also the close()
method posts a do_close() call with a default constructed error object
which is not handled correctly.
I'm not sure why you need to use a loop in the main routine, if you want
a server then use pending async calls to keep the io_service alive, if
you want a client then perhaps errors should simply cause graceful
... snip ...
-- Bill Somerville
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