It shouldn't, but your piece of code is too extense.
Try to reduce it to something simple and not related to other modules, like sending "The quick brown fox jumps over the lazy dog" or something like that. Check you don't inadvertently call tcp_close() somewhere. The connection is closing because somehow you are closing it (or trashing memory).
You should have a tcp_sent() callback somewhere...
No matter what you do to get the data, your code should like this:

void mysend(struct tcp_pcb *pcb)
{
// Try to send as much data as can fit in buffer
u16_t send_len = tcp_sndbuf(pcb);

        ...
        if (send_len >= strlen(MY_STRING)) {
if(tcp_write(pcb, MY_STRING, (u16_t)strlen(MY_STRING), TCP_WRITE_FLAG_COPY) == ERR_OK) {
                        // data sent
                        ...
                }
        }
}

static err_t mysent(void *arg, struct tcp_pcb* pcb, u16_t len)
{
        ...
        mysend(mypcb);
        return ERR_OK;
}

static err_t mypoll(void *arg, struct tcp_pcb* pcb)
{
        ...
        // Retry closing the connection
        // or
        // Retry sending data we couldn't send before
        mysend(pcb);
        return ERR_OK;
}

main:
        tcp_sent(mypcb, mysent);
        tcp_poll(mypcb, mypoll, POLL_TIME);


You can add a tcp_output() to force sending, otherwise it will go out eventually when some timer expires.

Here's how to use TCP:
http://lwip.wikia.com/wiki/Raw/TCP


_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to