
Hi guys, this is my first post to this mail list. Forgive my noob
questions, I am new to boost.
I have read some documentations but still dont understand how io_service
works.
My problem is that I need two functions in my server class, listen() and
handle()
listen() is to accept all incoming connections and bind them with a handler
function which accept a socket as argument.
and handler will simply call io_service.run()
=========================
class Server
{
io_service IOService;
std::vector

Shenyu Yao
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
participants (2)
-
Sam Miller
-
Shenyu Yao