Reputation: 1133
The basic logic is as follows
main_thread:
for(;;) {
accept socket
async_read head(length of packet),binded to head_handler
io_service.run() }
head_handler(non-thread):
async_read body(using length read from head) ,binded to body_handler
body_handler(non-thread):
parse message into Request objects (custom class).
push Request to request_pool
read_thread:
for(;;) {
if request_pool not empty (lock otherwise) { perform actions described by the Request } }
So I have a simple echo server using above logics. It prints out whatever messages passed in.However, only the first message will be displayed, all others will have "xxx.xxx.xxx.xxx connected" message printed out correctly.But no messages are printed
Upvotes: 0
Views: 376
Reputation: 15075
If you do not issue any async. operation in body_handler
, io_service
runs out of work and io_service::run()
exits. Before any subsequent call to io_service::run()
you have to call io_service::reset()
.
Upvotes: 2