• 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: Acquiring an NSConnection otherwise than by registered name?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Acquiring an NSConnection otherwise than by registered name?


  • Subject: Re: Acquiring an NSConnection otherwise than by registered name?
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 30 Sep 2010 11:45:37 -0500

On Sep 30, 2010, at 11:17 AM, Oleg Krupnov wrote:

> NSSocketPort* port = [[NSSocketPort alloc] initWithTCPPort:1234];
> NSConnection* connectionPoint = [[NSConnection alloc]
> initWithReceivePort:port sendPort:nil];
> if ([connectionPoint registerName:CONNECTION_NAME
> withNameServer:[NSSocketPortNameServer sharedInstance]])
>
> This time it registered, but on client side I get nil when asking for proxy:
>
> proxy = [NSConnection
> rootProxyForConnectionWithRegisteredName:CONNECTION_NAME host:nil];
>
> I get nil. I tried "localhost" and "128.0.0.1" for host, but still no luck.

Try +rootProxyForConnectionWithRegisteredName:host:usingNameServer: and specify the socket port name server (similar to what you did, above).

> There must be something simple I've overlooked? The docs do not tell
> how to set up sockets easily, only Mach ports come by default...

There are multiple approaches.  You can use the initializers of NSSocketPort to create socket ports.  You can use one of the -portForName:... methods of NSSocketPortNameServer to obtain a socket port for communicating with the named service.

Once you have the socket ports, you can create NSConnection objects from them, as you did above.

Cheers,
Ken

_______________________________________________

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: Acquiring an NSConnection otherwise than by registered name?
      • From: Oleg Krupnov <email@hidden>
References: 
 >Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Oleg Krupnov <email@hidden>)
 >Re: Acquiring an NSConnection otherwise than by registered name? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: NSOperation -dealloc not called
  • Next by Date: RE: Should I use NSDocument, NSUserDefaults or something else
  • Previous by thread: Re: Acquiring an NSConnection otherwise than by registered name?
  • Next by thread: Re: Acquiring an NSConnection otherwise than by registered name?
  • Index(es):
    • Date
    • Thread