[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] netconn_write semantic with NETCONN_NOCOPY flag
From: |
Kieran Mansley |
Subject: |
Re: [lwip-users] netconn_write semantic with NETCONN_NOCOPY flag |
Date: |
Sat, 24 Sep 2011 20:04:04 +0100 |
On 24 Sep 2011, at 09:32, Simon Goldschmidt wrote:
> TCP has to keep data buffer for retransmission until it is ACKed by the
> remote host. There'd ere, it needs to maintain unchanged for a while. You can
> either pass *static* data to netconn_write (NOCOPY), or tell netconn_write to
> copy data into internal buffers. However, this means extra memcpy plus extra
> buffer allocation (up to the amount of the TCP window).
So, just to avoid any room for confusion, this means you can't re-use and
modify a buffer sent using netconn_write() as there isn't a way to find out
when it is safe to do so. If you application-level protocol lets you deduce
this (e.g. if you receive a response to the query you sent using
netconn_write() then you can be sure that the query's buffer has now been
transmitted successfully) you could probably then modify the original buffer,
but I would avoid that if possible and stick to either "static data with
NOCOPY" or "dynamic data with COPY" unless you're sure you know you can safely
break this rule without causing problems.
Kieran