Re: 1. NSStream Questions (Jon Loeliger)
Re: 1. NSStream Questions (Jon Loeliger)
- Subject: Re: 1. NSStream Questions (Jon Loeliger)
- From: John MacMullin <email@hidden>
- Date: Fri, 16 Jul 2010 12:43:18 -0700
Create a dictionary with the stream as the key, access and maintain the dictionary and stream stuff with the key, (NSValue key), lock or synchronize access to the dictionary. Applies to every pass through handleEvent (and everywhere else), ie., any broadcast code.
That's what I do and it works just fine.
On Jul 16, 2010, at 12:02 PM, email@hidden wrote:
> 1. NSStream Questions (Jon Loeliger)
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 16 Jul 2010 10:15:49 -0500
> From: Jon Loeliger <email@hidden>
> Subject: NSStream Questions
> To: email@hidden
> Message-ID: <email@hidden>
>
> 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
>
>
Best regards,
John MacMullin
Attorney at Law
1-602-943-5240
1-602-904-5426
1-800-924-8548
Email:email@hidden
Skype: john_macmullin
www.macmullin.info
CONFIDENTIALITY - The information contained in this email is confidential information, may be legally privileged, and is intended only for the use of the individuals or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any disclosure, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone or by reply letter and delete or destroy the message in its entirety.
_______________________________________________
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