[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] netconn_write, "Flush" functionality
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] netconn_write, "Flush" functionality |
Date: |
Tue, 14 Jun 2011 14:25:33 +0200 |
"Walter Saegesser" <address@hidden> wrote:
> Quite a long time ago a read somewhere - don't ask me where, it was not
> on this mailing list - that a statement like "xNewConn->pcb.tcp->flags
> |= TF_NODELAY;" would force the netconn API to write data out
> immediately.
This is a *very* bad example since you are accessing internals of the stack.
Please use this code instead:
tcp_nagle_enable(xNewConn->pcb.tcp);
The tcp_nagle_*() functions were added in 1.4.0 only (I think) but using them
is strongly encouraged over directly accessing pcb members!
> What is the behavior of netconn_write if this flag is not set, i.e. what
> is the criterion to actually write the data?
The code you stated disables the nagle algorithm, which is enabled by default.
For details, see:
http://en.wikipedia.org/wiki/Nagle%27s_algorithm
> Is there in the meantime a more appropriate solution to flush the buffer
> at the end of a sequence of netconn_writes?
No, buffering data is TCP behaviour, not netconn specific. You could leave
nagle enabled until just before writing the last bytes, which would flush all
bytes out, but I think that's rather a hack, too.
Simon
--
NEU: FreePhone - kostenlos mobil telefonieren!
Jetzt informieren: http://www.gmx.net/de/go/freephone