Uploading file to FTP

Hi,
while uploading any file(say a .txt file) to FTP server after writing the last chunk of data for how much time do i have to wait to close the data and FTP channel using wip_close().
Before i used to close the channels immediatly after writing all the bytes to FTP server then i observed the last part of the data not being written to file.now m using a timer to close d channels after 1 minute from writing all the bytes. So please tell me the time after which i can close d channels writing d data fully n properly.

Since FTP is a File protocol, isn’t there a proper means to close the file…?

You can use wip_shutdown() instead of wip_close() followed by the wip_close () after the application received the WIP_CEV_PEER_CLOSE event

viewtopic.php?f=16&t=3146

Hello srikanthsoma,

Can you tell me how you chunked data??
I’m using

wip_write(c,buf2,strlen(buf2));

to write a file towards a FTP Server, the problem is: everytime the event WIP_CEV_WRITE is obtained,
my program find:

case WIP_CEV_WRITE:
adl_atSendResponse(ADL_AT_RSP,“\r\nWIP_sCEV_WRITE\n”);
wip_write(c,buf2,strlen(buf2));
break;

and It seems to me the writing procces is restarting
I would like to know what you did to separate data,

Any advice or help on how to acomplish this would be appreciated
:slight_smile:
javier

it seems to me that you need to check how much data was actually written, and then send the remaining data. instead of sending the same data over and over again, as your code currently does.

Hello!
srikanthsoma, I haven’t been able to solve the same problem you posted at the begining of this threat,
have you?

I used a timer to close the socket with the server but I don’t think that is the best way
javier

Normally, channel closing is not stupid: if you try to close a channel which has pending data in its buffers, it will silently go on serving them to the server, and only free resources once everything has been acknowledged. Here are a couple of ideas worth investigating:

  • Are you closing your bearer immediately after you closed the channels? If so, you can disrupt an IP route that was used by the channel to finish flushing its buffers. Unfortunately, bearers aren’t able to tell whether they support a communication being finalized.
  • Have you checked to values returned by wip_write( )? did it accept all the data you’ve pushed in it?

There is a way to know that a channel is really closed: you can use option WIP_COPT_FINALIZER, which attaches a callback to the channel, which will be run after all resources have been freed (including unacknowledged TCP buffers). This is an appropriate place to close the bearer, for instance.

thanks for answering srikanthsoma,

to avoid using a timer I was waiting to receive the
event WIP_CEV_PEER_CLOSE, I mean;

case WIP_CEV_PEER_CLOSE:
adl_atSendResponse(ADL_AT_RSP,"\r\nWIP_CEV_PEER wwCLOSE\n");
wip_close(ftp_conn_channel);
wip_close(ftp_tx_channel);
break;

but it takes too much time.

I’ll try adding WIP_COPT_FINALIZER to wip_putFileOpts function:

ftp_tx_channel = wip_putFileOpts(ftp_conn_channel,FTP_FILENAME,ftp_evh_put,NULL,WIP_COPT_FINALIZER,WIP_COPT_END);

but, where should I declare the callback function you mentioned?
(I couldn’t find it although I tried to find it in the manual)

Any advice or help on how to acomplish this would be appreciated
:slight_smile:
javier

hope not bothering you
with so many questions,

I wrote:

ftp_tx_channel = wip_putFileOpts(ftp_conn_channel,FTP_FILENAME,ftp_evh_put,NULL,WIP_COPT_FINALIZER,finalizer,WIP_COPT_END);

and some lines after:

void finalizer( void *ctx)
{
adl_atSendResponse(ADL_AT_RSP,"\r\nfinalizer\n");
}

and during the execution I see this:

//////////////////////////////////////////////
[WIP] new TCPCLIENT 0x180c7be0
[FTP=>] “220 Xlight FTP Server 3.1 ready…”
[FTP<=] USER midas

[FTP=>] “331 Password required for midas”
[FTP<=] PASS midas

[FTP=>] “230 Login OK”
[FTP<=] TYPE I

[FTP=>] “200 Type set to I.”
WIP_CEV_OPEN
Ftp connection OKERRLOG ftp.c:485: Option not supported
//////////////////////////////////////////////

any comment,??

javier

WIP_COPT_FINALIZER didn’t exist in the old versions of WIP. Check file wip.h for the declarations of WIP_COPT_FINALIZER and wip_finalizer_f. If you don’t find them, then your WIP version is too old.

Hi guys,

I’m strubbeling with the exactly the same problem:
I’m opening a ftp connection.
I’m starting a put file operation.
I’m sending data to the connection. After a while I’ve got to much data to be fit in the TX buffer so I send them in chunks (thanks to the WRITE event).
After the upload is done I call wip_shutdown
In the WIP_CEV_PEER_CLOSE event I call wip_close for both channels
In the finalizer I will close the GPRS bearer.

What I found out is that I get files of 0 bytes. When I 've got so much data that it won’t fit in the buffer a once, the file size starts to grow with about 1024 bytes. I never get the whole file uploaded, I always miss the last bytes so the upload isn’t finished.
I have seen that the post is quiet old, but I couldn’t find a proper solution yet. I asked my distributor, but I still didn’t received an answer.
How did you solved the problem?

thanks for your reply.

Stefan