Cocoa FTP

Discussion in 'Mac Programming' started by MacDonaldsd, May 3, 2008.

  1. MacDonaldsd macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #1
    Hi,

    There's a few Cocoa applications (using Objective-c) that I want to create that all require some FTP, SFTP interaction for uploading and downloading files.

    How do people recommend going about this ?

    Is there a C Library that does it, or is i built in to Cocoa somewhere?
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Basically you need to understand the protocol by reading the RFC document http://www.faqs.org/rfcs/rfc959.html and then you should be able to implement a client fairly easily using BSD sockets. Although Cocoa does have a higher level interface for networking BSD sockets will provide the greatest cross platform compatibility if you ever port to other OS's.
     
  3. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #3
    I don't know about Cocoa, but libcurl, bundled in /usr/lib as part of OS X, gives you a C-API for doing ftp, sftp, http, and other things.

    For more detail, you can read up on it here: http://curl.haxx.se/libcurl/

    (There's even a libcurl-tutorial manpage).

    There are also other open-source UNIX libraries, available from Mac Ports or Fink, for doing the job but I'd recommend curl.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    I've done it by reading the RFC before. It's not actually all that bad, but the good new is that someone else has done it for you.

    You want ConnectionKit :D
     
  5. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #5
    Thanks everyone,

    I think as my applications won't be just a FTP app, il use the connection kit, and if I have time il do my own FTP classes at a latter date.

    Hate to sound like a subversion newbie (which I am) how do I just download the whole source ?
     
  6. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #6
    You can also just call curl directly using NSTask, it's pretty easy.
     
  7. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #7
    svn co <server_name>

    I'd stick with the C stuff as I believe that Cocoa doesn't have good web support. I'd expect it to be improved for 10.6.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    You can setup Xcode 3.1 to download the entire project from the repository. Just enter the settings then checkout the project to some folder on your drive.

    It isn't too bad writing your own protocol implementation. I've been trying to do it with an NNTP reader for a while. It's my learning C project and it is going well.

    The hardest thing I found was making sure you sent the commands in the right order, some of the RFC documents are not very clear.
     
  9. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #9
    I've used the FTP stuff from ConnectionKit before ConnectionKit existed. It's just a Cocoa-ised wrapper around lot's of C calls. I'd use it. It's know to work and easy to use...
     
  10. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #10
    ^^ Interesting, I'd heard that the web Services stuff was a bit ***** in Cocoa. I assumed this would be the same. Of course that is a third party framework not an Apple native one.
     
  11. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #11
    FTP is not a web service.
    SFTP is not a web service...

    The built in SOAP/XML stuff is weak but it has nothing to do with transferring files.
     
  12. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #12
    As Core Data can't be used over the web I assumed most remote stuff was weak in Cocoa, clearly I'm wrong :eek:.
     
  13. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #13
    Hi all,

    I can't build and run the ConnectionKit project as it does not create an executable.

    Any ideas what I am doing wrong ?
     
  14. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #14
    It's a framework so isn't meant to create an executable. It should build a framework you can include in your own app.

    If you are trying to build the included sample app you probably have to change the target.
     
  15. Nutter macrumors 6502

    Joined:
    Mar 31, 2005
    Location:
    London, England
    #15
    This is like saying that most remote stuff is weak in Carbon, and therefore libcurl, which is also written in C, must be weak too.

    ConnectionKit is just a third-party framework. The fact that it's written in Objective-C, like Cocoa and the WebServicesCore framework, does not have any bearing on its ability to do the job.
     
  16. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #16
    OK, yeah it does build the framework fine.

    There is only 1 xcode project file, so how do I modify it to build the sample application ?

    Sorry im just a bit confused about it :eek:
     
  17. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
  18. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #18
    Thanks that works :D
     
  19. KartikGanesan macrumors newbie

    Joined:
    Apr 29, 2008
    #19
    Hi,

    Congrats to Greg and Team for implementing ConnectionKit.

    Integrating FTP was simple as the sample application was helpful.

    Has anyone integrated HTTP into their application yet?

    Do tell me how to achieve that

    Thanks

    KG
     
  20. dampi macrumors newbie

    Joined:
    Feb 3, 2009
    #20
    Hi!

    Could you upload some example code of yours? I do not know how to make it working. And what sample application do you mean?

    Thanks!
    Dampi
     
  21. urskaush macrumors newbie

    Joined:
    Mar 24, 2009
    #21
  22. dampi macrumors newbie

    Joined:
    Feb 3, 2009
    #22
    It is exactly like described on http://opensource.utr-software.com/connection/download.html

    Just go to console and type "svn co http://opensource.utr-software.com/source/connection"
    Doing so you check out the source code from a repositery

    You can even use XCode with SCM for doing this.

    HTH
    Damian
     
  23. machros macrumors newbie

    Joined:
    Mar 24, 2009
    #23
    Cocoa FTP

    Hi


    I want to create my own FTP .. i am new to cocoa... Please anyone suggest me which is the best way for creating FTP....using connectionkit or core foundation network.. thank you in advance..
     
  24. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #24
    If you use core foundation you will need to implement the entire protocol yourself. It'll be much easier to use connectionkit where this has been done for you.
     
  25. urskaush macrumors newbie

    Joined:
    Mar 24, 2009
    #25
    Cocoa FTP

    Hi
    Thank you.. Ya that is true ... But is there any documentation for connection kit framework?.. And how abt the support for multiple downloads...
     

Share This Page