|
From: | Noam Weissman |
Subject: | Re: [lwip-users] LW IP - TCP instantaneous data transmission |
Date: | Wed, 31 Aug 2016 10:28:45 +0000 |
Hi, Before you start re-inventing the wheel why not take a readymade HTTP server ? You have a basic good HTTP server in the lwIP contribution or similar that runs in RAW API. BR, Noam. From: lwip-users [mailto:lwip-users-bounces+address@hidden
On Behalf Of anand arjunan Hi, I am using LWIP (Raw TCP mode) (in FreeRTOS) for handling http page requests, construct the web page and send the page to the client. I have set the TCP_SND_BUF as 8*TCP_MSS where TCP_MSS is 1460. There will be only one client / browser
connecting to the system at a time. In the receive call back function, I constructed the entire web page and used the tcp_write () (with TCP_WRITE_FLAG_COPY ) to send the data to LWIP buffer. Due to memory limitations, I have to reuse a buffer size of 2.5 K to construct the
page before writing it to LWIP using tcp_write () as the actual page size to be sent to client is more than 14 K. I was thinking that as and when I call tcp_output () the data would be sent instantaneously to the client. But, I got to know that tcp_Output()
does not work in the callback function and LWIP will start sending the packets automatically once the control is out of the callback function. Due to this limitation I slightly modified the design. I have made the actual LWIP receive callback to just set another (second) callback function so that the actual LWIP callback would return immediately (so that tcp_output( ) can work).
The second callback would actually construct the page and would be invoked by http_poll function or some other timer. Even this does not work. It still accumulates the data worth of of 8*1460 bytes fully and sends only that much to the client. Once the buffer is full, tcp_sndbuf(pcb) returns zero and I cannot write anymore to it. I thought this would return
non zero value as I am calling tcp_output ( ) outside the LWIP calling function using a timer function. I tried disabling the nagle's algorithm using tcp_nagle_disbale( ) before transmitting the packets. That did not help either. I want the data to be sent to the client (without accumulating) as and when I call tcp_output( ) because of the limitation that I can construct only 2.5 K bytes of page at a time and reuse it to construct the next section of the page. Please help. Any help / pointers would be appreciated. Thanks LWIP_Starter |
[Prev in Thread] | Current Thread | [Next in Thread] |