0

Update:

I am going to use detach since my plan is to shut down the application, so I don't need join. Please correct me if I am wrong.

Original question

I am following the asioref-1.10.6 example for the TCP server with asynchronous mode. I don't have boost, so I am using C++11 std thread to allow both server and client working in same project.

I encountered this error:

Debug Error! ... abort() has been called ) Press Retry to debug the application. Abort/Retry/Ignore

What I did:

  1. I put server example in a function asynServe()

    asio::io_service io_service;
    tcp_server server(io_service);
    backService = &io_service;
    io_service.run();
    
  2. put a main function, so it will wait for the client thread to finish.

    std::thread t1(asyncServe);
    std::thread t2(asyncClient);
    
    t2.join();
    tryshutdown();
    //t1.join();
    int a;
    std::cin >> a;
    
  3. Put a shutdown function which just calls backService->stop(); I want to stop the server thread when the client finishes the job.

What happened is if I don't have t1.join() in the main, the Abort/Retry/Ignore dialog will show up. If I have t1.join there, then it would not show this dialog. What causes this problem?

I put Linux tag because I finally will port this project to Linux. So I hope this solution is not going to cause Linux problem.

Tanner Sansbury
  • 51,153
  • 9
  • 112
  • 169
Splash
  • 1,288
  • 2
  • 18
  • 36

0 Answers0