Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top