Re: Acquiring an NSConnection otherwise than by registered name?
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