lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] lwip FTP - TCP - packets problem


From: A480G
Subject: Re: [lwip-devel] lwip FTP - TCP - packets problem
Date: Mon, 18 Jul 2016 07:11:16 -0700 (MST)

Hello Sergio, 

Sorry for using the wrong list, I'll make sure for future I'll post there. 
A bit late answer to your question, I hope that not going to be a problem. 
Ok, I have mentioned already what is my problem, transferring large file
with a FTP. The board that I'm using is a SAM4E-Ek by Atmel, ans I'm using a
RTOS I think that will be good to know. 

  *static void ftpd_send_file(struct ftpd_datastate *fsd, struct tcp_pcb
*pcb)
{
        

        u16_t count;
        UINT read;
        if (!fsd->connected)
        {
                return;
        }
                
        do {
        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, 0);
                tcp_output(pcb);
//              if(f_size(fsd->fil) > fsd->filepos)
//                      return;
                }
        
        } while (f_size(fsd->fil) > fsd->filepos);

        
        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);
}*

above is my function where I try to loop a file and send packets via
*ftpd_data_write*

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);
                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;
}

This is the approach that I'm trying to use to send packets, but
unfortunately after the the 3 hand handshake of the tcp I'm not receiving
any packets !!!!! 

I was wondering if I need to use sockets, for the purpose?!

Thanks 




--
View this message in context: 
http://lwip.100.n7.nabble.com/lwip-FTP-TCP-packets-problem-tp26802p26816.html
Sent from the lwip-devel mailing list archive at Nabble.com.



reply via email to

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