lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] tcp echo example


From: Sergio R. Caprile
Subject: Re: [lwip-users] tcp echo example
Date: Fri, 01 Aug 2014 18:46:12 -0300
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Not really.
tcp_write() allocates an internal pbuf itself, but you can only send 3
times in a row if yu have enough memory, and as TCP works, there is no
concept of packet and no need to call 3 times in a row. You have a
sndbuf and you can send as much as you can fit inside that sndbuf for
that pcb. Once your buf is filled, you can only send again once data has
been sent out, acknowledged by the receiver, and so that buffer freed,
and that is signalled to you via the tcp_sent() callback.
The whole point of calling echo_send() from inside the callback function
is that in this case the total amount of data actually sent might not
equal the amount of data received (in the whole pbuf). The first call to
tcp_write() sends only the first pbuf in the pbuf chain, and once this
is acked, the tcp_sent() callback will try to send the remaining pbufs
in the chain.
A pbuf may be a chain of pbufs, linked by p->next

Either you have some memory problems or I've been lucky enough to get
whole data inside a single pbuf and didn't trigger the possible bug. I
recall sending small packets, what are you sending ? Again, I suggest
you use netio for big chunks of data.
I don't have the time to build a short tcp_mss version of my linux port
and try it, maybe on monday. I suggest you (besides going for netio) try
with small messages, I'm sure those work OK. If they do, then check the
pbuf chains, if they don't... check your port.

Regards

-- 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]