lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Large File transfer-- FTP lwIP 1.4.1


From: Sergio R. Caprile
Subject: Re: [lwip-users] Large File transfer-- FTP lwIP 1.4.1
Date: Fri, 5 Aug 2016 17:40:01 -0300
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

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




reply via email to

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