|
Boost Users : |
Subject: Re: [Boost-users] asio: async_write handler not called in Linux but called in Windows
From: Lloyd (lloydkl.tech_at_[hidden])
Date: 2015-07-21 01:33:32
I have enabled "BOOST_ASIO_ENABLE_HANDLER_TRACKING" and checked what is
happening... The relevant and partial output is given below...
This output is for a buffer of 32KB in size.
@asio|1437455926.606762|9*10|socket_at_0xb6601154.async_send
@asio|1437455926.606885|<9|
@asio|1437455926.606910|>10|ec=system:0,bytes_transferred=28960
@asio|1437455926.606930|10*11|socket_at_0xb6601154.async_send
@asio|1437455926.606940|<10|
@asio|1437455926.608395|>11|ec=system:0,bytes_transferred=3808
//**** Here it enters my write handler *****//
@asio|1437455926.620076|11*12|socket_at_0xb6601154.async_send
@asio|1437455926.620211|<11|
@asio|1437455926.620224|>12|ec=system:0,bytes_transferred=32768
//**** Here it enters my write handler *****//
@asio|1437455926.620451|12*13|socket_at_0xb6601154.async_send
@asio|1437455926.620486|<12|
@asio|1437455926.620496|>13|ec=system:0,bytes_transferred=16464
@asio|1437455926.620505|13*14|socket_at_0xb6601154.async_send
@asio|1437455926.620515|<13|
@asio|1437455926.622322|>14|ec=system:0,bytes_transferred=16304
//**** Here it enters my write handler *****//
@asio|1437455926.622549|14*15|socket_at_0xb6601154.async_send
@asio|1437455926.622573|<14|
@asio|1437455926.622588|>15|ec=system:0,bytes_transferred=5416
@asio|1437455926.622597|15*16|socket_at_0xb6601154.async_send
@asio|1437455926.622617|<15|
@asio|1437455926.622626|>16|ec=system:0,bytes_transferred=4344
@asio|1437455926.622635|16*17|socket_at_0xb6601154.async_send
@asio|1437455926.622645|<16|
@asio|1437455926.624319|>17|ec=system:0,bytes_transferred=18824
@asio|1437455926.624341|17*18|socket_at_0xb6601154.async_send
@asio|1437455926.624354|<17|
It has so much data more to be written, but the handler (18) is not getting
called! In the documentation it is stated that "async_write" is a composed
operation of "async_write_some". But here it seems it is using
"async_send". The code works as expected in windows! I am using Ubuntu
14.4 LTS.
Can anybody give some hint to debug this issue?
Thanks a lot,
Lloyd
On Fri, Jul 17, 2015 at 1:45 PM, Lloyd <lloydkl.tech_at_[hidden]> wrote:
> Further debugging the issue, I found that if I pass a small buffer (like
> 10KB) to write, the async_write handler (HandleWrite) is called. I was passing
> 128 MB of data to be written in a single async_write call. Does this has
> something to do with not calling the write handler? In Wondows also I am
> passing 128 MB buffer, but it works!
>
> On Thu, Jul 16, 2015 at 3:03 PM, Lloyd <lloydkl.tech_at_[hidden]> wrote:
>
>> Hi,
>>
>> I have an application that need to work on both Windows and Linux. We are
>> using asio for network communication (boost 1.57). In this, once the
>> connection is established with the server, the connection handler in client
>> executes the following async calls...
>>
>> boost::asio::async_read_until(Socket, stream, string("\r\n"),
>> boost::bind(&MyConnection::HandleRead, shared_from_this(),
>> boost::asio::placeholders::error));
>> ...
>> ...
>> ...
>> boost::asio::async_write(Socket,boost::asio::buffer(buff,len),
>> boost::bind(&MyConnection::HandleWrite,shared_from_this(),
>>
>> boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
>>
>> On Windows, the "HandleWrite" function is called as soon as the data is
>> written. But on Linux this function never gets called!. In Linux and
>> Windows HandleRead is getting called as expected.
>>
>> In bot the the case, the server receives the data properly. Is there any
>> reason for this?
>>
>> Thanks,
>> Lloyd
>>
>>
>
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