• 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: NSConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSConnection


  • Subject: RE: NSConnection
  • From: "Phil Barrett" <email@hidden>
  • Date: Thu, 6 Feb 2003 14:08:57 -0000

SDerman wrote:
> theProxy = [[NSConnection
> rootProxyForConnectionWithRegisteredName:@"XXXX"
> host:hostName] retain];
> [theProxy test]; <--- theProxy is nil
...
> Anyone see what I'm doing wrong as to why the apps can't talk over
> the network. I have some of it right since the app can talk to
> itself via NSConnection if I give an empty hostname.

Registered names don't work across a network, because there's no network
name server.

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];
if(conn)
{
[conn setReplyTimeout:10.0];
[conn setRequestTimeout:10.0];
NS_DURING
proxy = [[conn rootProxy] retain];
NS_HANDLER
proxy = nil;
if(hostname)
printf("Connection to server on %s could not be queried.\n", [hostname
cString]);
NS_ENDHANDLER
}
else
{
if(hostname)
printf("Connection to server on %s could not be opened.\n", [hostname
cString]);
}
[proxy test];

Phil
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSConnection
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Internet Config Example under Cocoa
  • Next by Date: Re: NSWorkspaceDidTerminateApplicationNotification and background app
  • Previous by thread: Re: NSConnection
  • Next by thread: Re: NSConnection
  • Index(es):
    • Date
    • Thread