On Wed, Mar 19, 2008 at 1:38 PM, Jeff LaMarche <[EMAIL PROTECTED]>
wrote:

> On Mar 19, 2008, at 1:26 PM, Sherm Pendley wrote:
>
> > IMHO, a single socket() call, although admittedly a bit old
> > school :-), is a little cleaner than reflecting a CF callback to an
> > Objective-C method.
>
> Cleaner? You'll get no argument from me on that. It took me a lot of
> playing around to wrap my head around how the CFNetwork classes work
> and to get them work in an Objective-C class.
>
> > All you need to do is call socket() to create the socket descriptor,
> > then pass that to NSFileHandle's -initWithFileDescriptor:
> > initializer. After that, it's all standard Cocoa methods to read,
> > write, and listen for incoming connection requests.
>
> Sound simple enough. In fact, rather obvious now that you mention it,
> though I've never used NSFileHandle's asynchronous methods before. I'm
> looking forward to trying it out, though - it sounds like it would
> make for simpler, and more easily maintained code.


Hmmm... Actually, now that I'm looking a second time, it looks like you need
to call both socket() to create the socket, then connect() to connect to a
remote host as a client. Then you can use NSFileHandle to do the reading and
writing.

For a server, you can use socket() to create the socket, then NSFileHandle's
-acceptConnectionInBackgroundAndNotify to accept client connections.

It strikes me as kind of odd that NSFileHandle doesn't have an initializer
that wraps the socket() or methods to wrap connect() or listen(), but it
*does* have a wrapper method for accept(). Time to file a feature request, I
think. :-)

sherm--
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to