0 Replies Latest reply on Oct 15, 2010 4:25 AM by Piotr Wierzgała

    socket, ftp, file upload

    Piotr Wierzgała

      Hi,

       

      I'm writting a library to manage ftp socket connections in AIR app. I'd like to implement a file upload operation but I need to answer some questions first.

       

      1. How big should be single package of data I send to server?

      2. How often packages can be sent?

       

      • Running through the web I found examples where people sent packages at 4kb/300ms, 10kb/120ms.
      • SmartFTP client sends 128kb/??. I wrote "??" because it seems that frequency of sending packages differs in a time.
      • WinSCP client allows to set a limitation on upload transfer (8 - 1024 kb/s) but it also has a "unlimited" option. How does it know what is the maximum transfer at a moment?

       

      • When I flushed 4kb each 1ms FTP server managed to receive only a part of my packages. Then I changed 1ms to 10ms and FTP server still didn't receive all packages but it received more than in previous case. Finally I set 100ms rate and the file was transfered properly. This test makes me to belive that package size and flush frequency really matters. I'm pretty sure that event if I send packages at 100ms rate it could cause some problems in cases when internet connection is low. I hoped that server may return some response when it receives package so I could know than next package can be send but nothing like that happens.
      • I also tried to flush a whole file at once because I belived that is the way to get maximum file transfer and it worked but I'm affraid it's not a good solution. I'm affraid that it may cause some problems on a server-side because of too much data at once. It's just a hunch so let me know if I'm wrong, please.

       

      3. How do I know if file was sent properly?

       

      • The only thing that comed to my mind was sending SIZE command after closing passive connection and comparing local file size with remote file size. But if sizes don't match then what? Delete remote file and send it againg? It seems weird. For all my life I didn't see a situtation in which ftp client didn't manage to send a file and even if that it tried to resend it.

       

      4. How can I estimate upload transfer?

       

      • I can't rely on the amount of data I send because I can send 1kb/s as well as whole file at once and it won't reflec the real transfer. I need to know somehow how much of the data I send was received be server. Again SIZE command comed to my mind. I thought that while uploading I could send SIZE command at some time interval like 1000ms and estimate by that how many bytes is received by server each second. Unfortunately server doesn't respond to SIZE command until file transfer is complete.
      • I'm lack of ideas: server doesn't return any confirmation that package was received and I can't do it by checking remote file size. What else can I do?

       

      If you can't help me I'll be glad if you poit me out a place where I could introduce my problem. It's difficult to find a forum about wrtting ftp client issues