Even if you just want to download a file, the Mac has a number of APIs to choose from.

Open Transport exists in Carbon, but is rather complicated and is not undergoing further development.

URL Access exists in Carbon, but is deprecated and buggy.

CFURLAccess, such as the function CFURLCreateDataAndPropertiesFromResource, can be used to download a file with a minimum of fuss, but without any indication of progress or ability to abort the download.

BSD APIs such as BSD sockets and the libCurl library may appeal to you if you're trying to write code that is portable to other Unix platforms.

NSURL is the main Cocoa class for downloading.

CFNetwork is a set of Core Foundation networking APIs. In particular, the CFReadStream APIs can be used to download by FTP or HTTP without any need to write threads or interrupt-time code.


a list of developer sample code for networking is here. [samplecode]

I found this example to be helpful. [CFNetworkHTTPDownload]

There is also a nice example of wrapping NSDownload for use in Carbon, should be on your drive at: /Developer/Examples/WebKit/CarbonDownloader/

And more Carbon examples in the /Developer/Examples/Networking folder.


Thank you very much. Is there any CFSocket server/client sample code?