• 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: Network communication with NSFileHandle & NSSocketPort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Network communication with NSFileHandle & NSSocketPort


  • Subject: Re: Network communication with NSFileHandle & NSSocketPort
  • From: Jeff LaMarche <email@hidden>
  • Date: Wed, 19 Mar 2008 14:01:24 -0400


On Mar 19, 2008, at 1:57 PM, Sherm Pendley wrote:

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. :-)


Do you think this would work as an alternative?

NSSocketPort *port = [[NSSocketPort alloc] initRemoteWithTCPPort:portNum host:@"theserver.com"];
int fd = [port socket];
NSFileHandle *fh = [[NSFileHandle alloc] initWithFileDescriptor:fd];


Thanks,
Jeff
_______________________________________________

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


  • Follow-Ups:
    • Re: Network communication with NSFileHandle & NSSocketPort
      • From: "Sherm Pendley" <email@hidden>
    • Re: Network communication with NSFileHandle & NSSocketPort
      • From: Chris Parker <email@hidden>
References: 
 >Network communication with NSFileHandle & NSSocketPort (From: "Valentin Dan" <email@hidden>)
 >Re: Network communication with NSFileHandle & NSSocketPort (From: Jeff LaMarche <email@hidden>)
 >Re: Network communication with NSFileHandle & NSSocketPort (From: "Sherm Pendley" <email@hidden>)
 >Re: Network communication with NSFileHandle & NSSocketPort (From: Jeff LaMarche <email@hidden>)
 >Re: Network communication with NSFileHandle & NSSocketPort (From: "Sherm Pendley" <email@hidden>)

  • Prev by Date: Re: Network communication with NSFileHandle & NSSocketPort
  • Next by Date: Re: Intercepting retain/release of object
  • Previous by thread: Re: Network communication with NSFileHandle & NSSocketPort
  • Next by thread: Re: Network communication with NSFileHandle & NSSocketPort
  • Index(es):
    • Date
    • Thread