Re: Network communication with NSFileHandle & NSSocketPort
Re: Network communication with NSFileHandle & NSSocketPort
- Subject: Re: Network communication with NSFileHandle & NSSocketPort
- From: "Sherm Pendley" <email@hidden>
- Date: Wed, 19 Mar 2008 13:26:56 -0400
On Wed, Mar 19, 2008 at 9:44 AM, Jeff LaMarche <email@hidden>
wrote:
>
> On Mar 19, 2008, at 5:58 AM, Valentin Dan wrote:
> > I need to send and receive message over the network but I got stuck …
>
> Surprisingly, there is no general-purpose Cocoa wrapper for the
> CFNetwork foundation functions. There are several specific wrappers -
> such as NSURLConnection and NSURLDownload, but if you want to do low-
> level socket communication with a protocol other than HTTP or FTP,
> you're going to have to get your hands a little dirty.
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.
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.
sherm--
_______________________________________________
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