Re: NSConnection
Re: NSConnection
- Subject: Re: NSConnection
- From: Douglas Davidson <email@hidden>
- Date: Thu, 6 Feb 2003 09:28:32 -0800
On Thursday, February 6, 2003, at 06:08 AM, Phil Barrett wrote:
Registered names don't work across a network, because there's no
network
name server.
Actually, as of Jaguar, NSSocketPortNameServer does use Rendezvous, so
in the example below the server could add [[NSSocketPortNameServer
sharedInstance] registerPort:port name:@"foo"] and the client could
then use [[NSSocketPortNameServer sharedInstance] portForName:@"foo"
host:host], where host is a host name, or a dotted quad IPv4 address
(or the IPv6 equivalent, if you are using IPv6), or nil for localhost,
or "*" to match any host.
There are some limitations associated with this use of Rendezvous for a
port name server; see the Foundation release notes for Jaguar for more
information. For more sophisticated usages it should be
straightforward to use NSNetServices directly to advertise and look up
ports. If you need to go beyond the local Rendezvous domain you will
probably need to do some additional work.
Douglas Davidson
Either use Rendezvous (which I haven't looked at), or use a numbered
port:
Server:
NSSocketPort * port = [[[NSSocketPort alloc]
initWithTCPPort:SERVER_PORT] retain];
NSConnection * conn = [[NSConnection connectionWithReceivePort:port
sendPort:nil] retain];
[conn setRootObject:self];
Client:
NSDistantObject * proxy = nil;
NSSocketPort * port = [[NSSocketPort alloc]
initRemoteWithTCPPort:SERVER_PORT host:hostname];
NSConnection * conn = [[NSConnection connectionWithReceivePort:nil
sendPort:port] retain];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.