problem with boost io_service

Hello, I have an application in which I created an io_service object in the main thread of the application. Then I created a listener object (listener socket class), this class creates a new worker thread and waits for incoming messages. First I created listener socket in the context of the main thread and called async_receive_from() so that io_service has something to work, and then I called io_service.run() in the worker thread. But the run() returned immediately. So I tried creating the socket in the worker thread and called async_receive_from() and then called io_service.run(). Again run() returned immeidately with boost::system::error_code's m_val = 0. Can someone point me in the right direction? i m kind of clueless.. Thanks, Bharani _________________________________________________________________ Talk to your Yahoo! Friends via Windows Live Messenger. Find out how. http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yah...

On Sat, 30 Aug 2008 12:41:52 +0200, lakers fan <lakersfan74@msn.com> wrote:
Hello, I have an application in which I created an io_service object in the main thread of the application. Then I created a listener object (listener socket class), this class creates a new worker thread and waits for incoming messages. First I created listener socket in the context of the main thread and called async_receive_from() so that io_service has something to work, and then I called io_service.run() in the worker thread. But the run() returned immediately. So I tried creating the socket in the worker thread and called async_receive_from() and then called io_service.run(). Again run() returned immeidately with boost::system::error_code's m_val = 0. Can someone point me in the right direction? i m kind of clueless..
Is it possible that your handler which you passed to async_receive_from() was called? If you don't call async_receive_from() then again from your handler the io_service has no work to do anymore (and run() returns). Boris

As soon as I created the socket, I called async_receive_from() before io_service.run(). But run() returns immediately. Thanks, Bharani> To: boost-users@lists.boost.org> From: boriss@web.de> Date: Sun, 31 Aug 2008 00:47:02 +0200> Subject: Re: [Boost-users] problem with boost io_service> > On Sat, 30 Aug 2008 12:41:52 +0200, lakers fan <lakersfan74@msn.com> wrote:> > >> > Hello,> > I have an application in which I created an io_service object in > > the main thread of the application. Then I created a listener object > > (listener socket class), this class creates a new worker thread and > > waits for incoming messages. First I created listener socket in the > > context of the main thread and called async_receive_from() so that > > io_service has something to work, and then I called io_service.run() in > > the worker thread. But the run() returned immediately. So I tried > > creating the socket in the worker thread and called > > async_receive_from() and then called io_service.run(). Again run() > > returned immeidately with boost::system::error_code's m_val = 0.> > Can someone point me in the right direction? i m kind of clueless..> > Is it possible that your handler which you passed to async_receive_from() > was called? If you don't call async_receive_from() then again from your > handler the io_service has no work to do anymore (and run() returns).> > Boris> > _______________________________________________> Boost-users mailing list> Boost-users@lists.boost.org> http://lists.boost.org/mailman/listinfo.cgi/boost-users _________________________________________________________________ Get thousands of games on your PC, your mobile phone, and the web with Windows®. http://clk.atdmt.com/MRT/go/108588800/direct/01/
participants (3)
-
Boris
-
Jonathan Biggar
-
lakers fan