Boost logo

Boost Users :

Subject: Re: [Boost-users] Reusing IOService Object
From: Alexander Sack (pisymbol_at_[hidden])
Date: 2008-10-27 15:53:31


On Mon, Oct 27, 2008 at 2:37 PM, Tim Pynegar <tim_at_[hidden]> wrote:
> Hi,
>
> I'm having an issue starting then stopping and trying to restart a socket or
> rather the IOService that's being used to service that socket.
>
> The IOService and Socket are member's of my class that has a run method
> itself that is on a separate thread.
>
> In my class constructor the Socket is passed into the IOService constructor.
>
> The sequence is as follow's
>
> Socket.Open
> Socket.Bind
> Socket.async_recieve_from
>
> Thread Start ------
>
> IOService.Run
>
> Socket.Close
>
> IOService.Stop ( the thread terminates due to the IOService.Run method
> completing )
>
> Socket.Open
> Socket.Bind
> Socket.async_recieve_from
>
> Thread Start ------
>
> IOService.Run
>
> This then return's immediately due to a "stopped" long in IOService ( on
> windows ) being set to 1.
>
> So my question is really am i trying to use these in the wrong way as in
> should i construct a new Socket and IOService for each
> time i want to start them or is there some way to reset the IOService to
> it's original state beyond calling IOService.Stop.

Tim:

See:

http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/reference/io_service/reset.html

-aps


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