Boost logo

Boost Users :

Subject: Re: [Boost-users] pass asio socket to another class
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-01-05 16:47:54


On 13/12/2014 05:00, cap wrote:
> Sorry, I've forgot to specify a /Listener/ class:
>
> void Listener::Init(void)
> {
> for (UINT i = 0; i < 10; ++i)
> {
> IoServicePtr service(new IoService());
> m_PtrIoServices.push_back(service);
> m_WorkIoServices.push_back(IoService::work(*service));
> m_Threads.create_thread(boost::bind(&IoService::IO_SERVICE_THREAD_VOID,
> service));
> }
> }

Why are you creating multiple I/O services? Typically you should create
a single io_service and 1-N threads calling io_service::run on that service.

> void handle_handshake(
> const boost::system::error_code& error)
> {
> if (!error)
> {
> memset(request_, 0, max_length);
> strcpy_s(request_, "GET https://www.google.com.ua/ HTTP/1.1");
> size_t request_length = strlen(request_);

After this completes your code immediately goes to read from the
connection. HTTP servers will typically not send any reply data until
you send a complete request -- which the above is not since it is
missing several headers required by HTTP/1.1 and most importantly is
missing the CRLFCRLF request terminator.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net