c++ - Calling boost::asio::read() in a thread blocks calling thread or process? -
i'm quite new network programming , i'm writing program should accept many tcp connections , receive data them. make things go parallel, agent should read data each socket in new thread. decided use boost::asio
instead of raw *nix sockets make things simpler. though seems wrong decision...
i wonder if calling boost::asio::read
or boost::asio::read_some
blocks calling thread or blocks process? yes should write own small test , see results myself, have no access linux box right now. thinking code should write tomorrow @ university.
so if blocks process, what's correct way of implementing server/client architecture accepts many clients @ same time?
notes:
- i'm having difficulties design decisions. suggestion appropriate.
the read , read_some calls both blocking, , block current thread linux , win32 (and others, don't have direct expericence).
you might want using async_read instead though if having large number of incoming connections, might acctually better performance wise using smaller number of threads number of connections. boost provide examples of using thread pool handle client connections.
Comments
Post a Comment