• 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: Sockets or NSStreams (was Re: mail-in db/app)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sockets or NSStreams (was Re: mail-in db/app)?


  • Subject: Re: Sockets or NSStreams (was Re: mail-in db/app)?
  • From: Alastair Houghton <email@hidden>
  • Date: Tue, 2 Oct 2007 14:13:36 +0100

On 2 Oct 2007, at 13:48, Marcelo Alves wrote:

On Oct 2, 2007, at 05:01 , Uli Kusterer wrote:

[ snip ]

One Cocoa-specific trick: After you've opened the socket, create an NSFileHandle for your connection. That makes reading/writing much more convenient. I just wrote myself wrappers for line-wise reading of ASCII strings and put them in an object of my own that owns the NSFileHandle. Worked beautifully. Also, keep in mind to do all this stuff on a second thread, so the user can use the GUI even while you're downloading e-mail.


Just a non-related question, why do you prefer sockets + NSFileHandle / (insert a network framework here) instead of NSStream? I'm asking because I'm working on a project and we went to NSStream route, and got SSL/TLS for "free".


<http://developer.apple.com/documentation/Cocoa/Conceptual/Streams/ Articles/NetworkStreams.html>

Indeed, I was also going to say that CF/NSStream is probably a better match for sockets. Also, I'm not sure if CF/NSStream suffer from the bug in various NSFileHandle methods where an EINTR return from a system call triggers an exception. (It shouldn't; it should just cause the code to retry the system call, but that's now how it works right now.)


(Since you mention it, it's worth noting, by the way, that SSL and TLS support is slightly limited, in that you don't get proper support for client certificates [because the underlying Secure Transport code still doesn't have that]. It might work as long as you only have a single client cert on your machine, but it won't work in the more general case where you may have more than one.)

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

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


References: 
 >mail-in db/app (From: RenĂ© v Amerongen <email@hidden>)
 >Re: mail-in db/app (From: "I. Savant" <email@hidden>)
 >Re: mail-in db/app (From: RenĂ© v Amerongen <email@hidden>)
 >Re: mail-in db/app (From: Uli Kusterer <email@hidden>)
 >Sockets or NSStreams (was Re: mail-in db/app)? (From: Marcelo Alves <email@hidden>)

  • Prev by Date: Sockets or NSStreams (was Re: mail-in db/app)?
  • Next by Date: NSCell subclass editing
  • Previous by thread: Sockets or NSStreams (was Re: mail-in db/app)?
  • Next by thread: Re: Sockets or NSStreams (was Re: mail-in db/app)?
  • Index(es):
    • Date
    • Thread