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: A480G
Subject: Re: [lwip-users] Large File transfer-- FTP lwIP 1.4.1
Date: Sun, 7 Aug 2016 06:05:15 -0700 (MST)

Hi Noam, 

Thanks for your reply. I think I know what your mean. the Following code is
doing the the same as you said:

*static err_t ftpd_data_write(struct tcp_pcb *pcb, const void* ptr, u16_t
*length, u8_t apiflags)
{
        int vurti; 
        u16_t len;
        err_t err;
        LWIP_ASSERT("length != NULL", length != NULL);
        len = *length;
        do {
                //LWIP_DEBUGF1(FTPD_DEBUG | LWIP_DBG_TRACE, ("ftpd-data: 
Sending %d
bytes\n", len));
                err = tcp_write(pcb, ptr, len, apiflags);
                tcp_output(pcb);
                if (err == ERR_MEM) {
                        if ((tcp_sndbuf(pcb) == 0) ||
                        (pcb->snd_queuelen >= TCP_SND_QUEUELEN)) {
                                /* no need to try smaller sizes */
                                len = 1;
                                } else {
                                len /= 2;
                        }
                }
        } while ((err == ERR_MEM) && (len > 1));

        *length = len;
        return err;
}*

ftpd_data_write() i called by: ftpd_send_file

*static void ftpd_send_file(struct ftpd_datastate *fsd, struct tcp_pcb *pcb)
{
        
        int r;
        u16_t count;
        UINT read;
        if (!fsd->connected)
        {
                return;
        }
                r = 1;

        if(tcp_sndqueuelen(pcb)>0) {
                tcp_output(pcb);
        }
        
        if(fsd->buf) {
                if(!fsd->filepos)
                        count = tcp_mss(pcb); // maximum data that can be 
transmitted 1460
                else
                        count = fsd->buf_size;
        } else {
                return;
        }
                if(count > tcp_sndbuf(pcb)) count = tcp_sndbuf(pcb);

                f_read(fsd->fil, fsd->buf, count, &read);
                fsd->filepos += read;
                if(read > 0) {
                ftpd_data_write(pcb, fsd->buf, (u16_t *)&read, 
TCP_WRITE_FLAG_MORE);
                tcp_output(pcb);
                
          if(f_size(fsd->fil) > fsd->filepos)
                return;
        }


        
        struct ftpd_msgstate *fsm;
        struct tcp_pcb *msgpcb;
        fsm = fsd->msgfs;
        msgpcb = fsd->msgpcb;
        f_close(fsd->fil);
        mem_free(fsd->fil);
        fsd->fil = NULL;
        ftpd_close_data_conn(pcb, fsd);
        fsm->datapcb = NULL;
        ftpd_data_state_free(fsm->datafs);
        fsm->state = FTPD_IDLE;
        send_msg(msgpcb, fsm, msg226);
}
*





--
View this message in context: 
http://lwip.100.n7.nabble.com/Large-File-transfer-FTP-lwIP-1-4-1-tp27025p27049.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

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