• 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
Re: Cocoa HTTP Server & threading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa HTTP Server & threading


  • Subject: Re: Cocoa HTTP Server & threading
  • From: Dustin Voss <email@hidden>
  • Date: Wed, 20 Dec 2006 13:58:00 -0800

On 19 Dec 2006, at 5:34 AM, Brad Peterson wrote:

--- Andrew Farmer <email@hidden> wrote:

(http://developer.apple.com/samplecode/CocoaHTTPServer/)

My first suggestion would be to take a close look at
TCPServer.m and
see where you can spin off a new thread for each
request.
TCPServerAcceptCallBack() looks like a good
candidate.

I agree that this is the right place, but I'm stumped. I don't mean to be dense but I don't see any way to convert this into something I can pass into NSThread's detachNewThreadSelector.

Also, I don't think that responding in a separate
thread is what I need, since I really want it to
listen for connections in a separate thread; to make
the entire TCPServer class run in its own thread.

You can listen to connections in a separate thread and handle them in that same thread. What you do is, you start the new thread and create all your server-related objects in that thread, and call all the read/ write methods in that thread as well.


If the main thread wants to interact with the remote apps in any way, you'll need to use some sort of system to pass data or commands back and forth from the server thread. See my response to the "passing data to threads" message.

_______________________________________________

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


References: 
 >Re: Cocoa HTTP Server & threading (From: Brad Peterson <email@hidden>)

  • Prev by Date: NSHost and host aliases
  • Next by Date: Re: Delegates -- WHAT is delegated?
  • Previous by thread: Re: Re: Cocoa HTTP Server & threadin
  • Next by thread: Intermittent crash that's driving me nuts... any ideas?
  • Index(es):
    • Date
    • Thread