Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::asio] how should I use accept and io_service?
From: Sam Miller (samjmill_at_[hidden])
Date: 2013-04-08 14:44:35


> Shenyu Yao <yaoxx123_at_[hidden]>
> everytime you instantiate a new socket object with a constructor
> including a io_service object, this socket object is associated with
> the io_service object, since I only have one io_service object,
> these socket object will be executed when I call io_service.run()
> but, the question is, how do i assign handle_function to those
> socket, I saw people use acceptor.async_accept(socket, boost::bind
> (handler, &socket)) like this, But I want to use accept rather than
> async_accept(), but the accept() function cant be used to bind a
> handler function to this socket

Use asynchronous methods if you only want to use one thread, otherwise use
synchronous (blocking) methods and create a thread per connection. There
are many asio examples showing how to do both.

Sam



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