문제

I'm having trouble sending more than one request to my server.
I'm using the boost asio async_client exemple

The problem is that I always get: Error Asio.misc 2 (eof reached I think).

I don't know if the good way to do this is to have a pool of threads or if I can reuse the same io_service, ...
I don't find good answers on how to do that on the web.
I only try to send another request after I have reach the EOF from the first one.

도움이 되었습니까?

해결책

The client class in the exemple wraps the whole process:

  1. The name resolution process
  2. The connection establishment
  3. The sending of the request
  4. The handling of the response

Once you reached EOF when reading the response, your connection is closed by the server (because of the HTTP Header). Therefor, you have to restart part of the process. You have to first re-establish a connection to the remote server, send your request, and read the response. It's probably not useful to redo name resolution.

If you really want to go the simple way, then creating a new client would probably work.

You don't need a pool of thread and you can certainly re-use your io_service object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top