how to run listener socket in a separate thread
Hello, I have a udp listener socket, I want that to run in a separate thread. Just listen for incoming messages and pass the message to message handler. I checked the tutorial, it shows boost::asio::io_service io_service; udp_server server(io_service); io_service.run(); I see the run() method running in a loop. Then how do I stop the service from some other thread?. Any help would be greatly appreciated. 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...
lakers fan wrote:
Hello, I have a udp listener socket, I want that to run in a separate thread. Just listen for incoming messages and pass the message to message handler. I checked the tutorial, it shows
boost::asio::io_service io_service; udp_server server(io_service); io_service.run();
I see the run() method running in a loop. Then how do I stop the service from some other thread?.
Any help would be greatly appreciated.
Arrange for a way for another thread can call top() on the first thread's io_service object. -- Jon Biggar Floorboard Software jon@floorboard.com jon@biggar.org
I see the run() method running in a loop. Then how do I stop the service from some other thread?.
Any help would be greatly appreciated.
Arrange for a way for another thread can call top() on the first thread's io_service object.
stop() sends a signal to end a threads execution of run(), so it's as simple as another thread holding a reference to io_service and invoking when required.
participants (3)
-
Alex Adranghi
-
Jonathan Biggar
-
lakers fan