I want to send a large http packet. 200KB length. But I can only work with
a 4KB buffer to dynamically generate the web page. I tried several ways
and all of them did not work. Seems tcp_write() function is doing some
queueing internally and I don't understand its logic. Anyway, I think it
should be a common problem for RAM limited controllers. I wonder how you
guys handle sending big packets when RAM is limited?
file.len=strlen(file.data);
hs->file = file.data;
hs->left = file.len;
send_data(pcb, hs);
tcp_output(pcb);
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
static void
send_data(struct tcp_pcb *pcb, struct http_state *hs)
{
err_t err;
u16_t len;
/* We cannot send more data than space avaliable in the send
buffer. */
if (tcp_sndbuf(pcb) < hs->left)
{
len = tcp_sndbuf(pcb);
}
else
{
len = hs->left;
}
err = tcp_write(pcb, hs->file, len, 0);
if (err == ERR_OK)
{
hs->file += len;
hs->left -= len;
}
}
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct http_state *hs;
hs = arg;
if (hs->left > 0)
{
send_data(pcb, hs);
}
else if(more_data)
{
more_data=(dump_data(0));
hs->file = html_total;
hs->left = strlen(html_total);
send_data(pcb, hs);tcp_output(pcb);
// tcp_sent(pcb, http_sent);
}
else
close_conn(pcb, hs);
return ERR_OK;
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users