• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Mixing network code with NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mixing network code with NSThread


  • Subject: Mixing network code with NSThread
  • From: "R. Tyler Ballance" <email@hidden>
  • Date: Tue, 30 Jan 2007 00:34:34 -0600

I'm working on a bit of painful networking code that really sits mostly on top of BSD sockets (CFNetwork doesn't appear to be as well suited for serving data as it is consuming it) and I was hoping to avoid the pain and complexity of pthreads for this (entire) application and get away with segmenting my code adequately enough to use NSThread in the classical concurrent thread-based server model.

Is this an avenue I should be avoiding? The basic model of the code I don't think would change much if I used stock pthreads, I think I'm really just substituting pthread_create() with [NSThread detachWithSelector:] right after I would be blocking on the accept() calls. (Inside the detached thread of course the method would handle the network I/O and then appropriately disconnect the client and kill the thread after the operations are complete) It almost seems _too_ easy, and I've found that when something is as easy as it seems in threading, it's probably broken :)

IPC from the detached selector would be relatively simple posting of NSNotifications to the main thread for handling (with retained objects), so that's not what I'm worried about, it just seems weird to mingle BSD socket code and NSThread together...in the same class even!

There doesn't seem to be an explicit Core Foundation abstraction for using threads (excluding pthreads) so is mixing this code with NSThread a viable option?


Cheers R. Tyler Ballance: Lead Mac Developer at bleep. software contact: email@hidden | jabber: email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Mixing network code with NSThread
      • From: Dustin Voss <email@hidden>
    • Re: Mixing network code with NSThread
      • From: Chris Parker <email@hidden>
  • Prev by Date: Design Decision: Multi-Array Table View
  • Next by Date: Re: Mixing network code with NSThread
  • Previous by thread: Design Decision: Multi-Array Table View
  • Next by thread: Re: Mixing network code with NSThread
  • Index(es):
    • Date
    • Thread