• 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
NSStream Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSStream Questions


  • Subject: NSStream Questions
  • From: Jon Loeliger <email@hidden>
  • Date: Fri, 16 Jul 2010 10:15:49 -0500

Folks,

I'm a bit new to Cocoa/iPhone programming, so I apologize
if this is Ye Olde Question Again.  Googling hasn't quite
anwered my quesion yet...

I'm writing a network server that needs to accept many
simultaneous client connections and keep track of them.
I've written the base server parts, roughly in the style
of the Apple Examples (SimpleNetworkStreamsExample).  These
examples, however, only allow one connected client.  I need
to manage several full duplex NSStream in/out pairs.

I can arrange to have a Connected Clients table that contains
both the inStream and outStreams created for the accepted fd
(CFSocketNativeHandle) using some class that glues the inStream,
outStream and clientNumber together in a table.

My problem originates at the point when the stream event
handling delegate is called:

    - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode

At this point I have the active stream, aStream, in hand, but
I don't know which client it belongs to.  Ultimately, this means
I can't reply to the client for lack of deriving its matching
outStream or clientNumber in my table.

Is there a (void *) data that I can associate with a NSStream
at the time I create it and later retrieve it at stream:handleEvent:
time?  Or do I have to search my client table for a matching
stream handle on every read/write event?

What am I missing?

Thanks,
jdl
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Prev by Date: RE: Trying hard to get all domains in network
  • Next by Date: Re: Reading in UTF-8 to Data
  • Previous by thread: NSResponder action messages not being received correctly
  • Next by thread: Re: NSStream Questions
  • Index(es):
    • Date
    • Thread