On Apr 29, 2010, at 5:26 AM, Paul Franz wrote:

I am trying to convert my Java code to Objective-C code and I have run
into a problem. I have thread, that currently has a socket open and it
sits there and send packets of information through the socket.

If you want to port existing code with the least effort this might be appropriate, but FYI this isn't how I/O is normally done in Cocoa apps. Instead, Cocoa uses asynchronous APIs that return immediately but notify a delegate/target object when data arrives. (For example, look as NSURLConnection or NSStream and their delegate APIs.)

You can certainly do multithreaded programming in Cocoa, but it's not as convenient as in Java because (a) you have to deal with the messiness of native code, (b) Cocoa doesn't have as rich a threading API, and (c) fewer classes are thread-safe because usage of threads isn't as common.

Again, I'm not saying you can't make this work, but you need to ask yourself whether your goal is just to port the code and get it to run, or whether you want to create a clean Cocoa codebase you can continue to develop on.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to