Re: Even more DO problems
Re: Even more DO problems
- Subject: Re: Even more DO problems
- From: Lloyd Dupont <email@hidden>
- Date: Tue, 10 Jun 2003 16:17:37 +1000
here is some code fragment I use to setup DO.
look more simple than what you do, but that might help, who knows ?
(there is some Rendezvous stuff intermixed, I hope you won't mind)
- (BOOL) registerServer
{
[self unregister];
NSConnection * conn = [NSConnection defaultConnection];
[conn setRootObject: self];
BOOL reg = [conn registerName: name];
if(port >= 0) {
NSSocketPort * sport = [[[NSSocketPort alloc]
initWithTCPPort:port] autorelease];
connection = [[NSConnection alloc] initWithReceivePort:sport
sendPort:nil];
[connection setRootObject:self];
service = [RendezvousHelper publish:name
port:[sport TCPPort] // in case
port = 0
ofType:type];
[service retain];
}
return reg;
}
+ (Server *) proxyWithService:(NSNetService *) aService
{
if(aService == nil)
return nil;
NSString * anHost;
int aPort;
if(! [RendezvousHelper getHost:&anHost port:&aPort from:aService]) {
IHLog("service not resolved");
return nil;
}
NSPort * nsport = [[[NSSocketPort alloc] initRemoteWithTCPPort:aPort
host:anHost] autorelease];
NSConnection * conn = [[[NSConnection alloc]
initWithReceivePort:nil sendPort:nsport] autorelease];
return (Server *) [conn rootProxy];
}
On Tuesday, June 10, 2003, at 03:52 PM, Sailor Quasar wrote:
>
On Tuesday, June 10, 2003, at 01:36 AM, Lloyd Dupont wrote:
>
> not sure if these ideas will help any. but...
>
>
>
> 1. Could it be that you haven't set up the sendport on the server
>
> correctly?
>
>
I don't set up the send port for the server. I only set up a receive
>
port and rely on the documented semantics of NSConnection for it to
>
set up the send port for the well-known server connection. The child
>
conections are supposed to use the same port semantics, as I
>
understand it.
>
>
> 2. Then you also have to think about your argument (NSData *)data. Is
>
> it going to also be a proxy object on the server to the client-owned
>
> data object ? So any calls on the server (eg [data doSomething] )may
>
> occur on the client side.
>
>
I pass it as (bycopy NSData *). Sorry, forgot to mention that before.
>
I specifically don't want the data object proxied.
>
>
> 3. you can get more control of the DO stuff if you look at the
>
> NSConnection delegates like
>
>
>
> - (BOOL)connection:(NSConnection *)conn
>
> handleRequest:(NSDistantObjectRequest *)doReq
>
>
I already use an NSConnection delegate, but I didn't know that that
>
method could be used. How would it help, frankly?
>
>
-- Sailor Quasar, just another player in The World
>
"Come with me in the twilight of the summer night for awhile"
>
Email: email@hidden
>
_______________________________________________
>
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.
_______________________________________________
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.