Re: Distributed Objects and Bonjour
Re: Distributed Objects and Bonjour
- Subject: Re: Distributed Objects and Bonjour
- From: Robert Sesek <email@hidden>
- Date: Thu, 29 Jun 2006 16:11:15 -0700
On Jun 28, 2006, at 6:22 PM, Adam R. Maxwell wrote:
Here again, you need to retain connection if it's an ivar. Also,
you need to run the call to -rootProxy inside an exception
handler, and catch any exceptions raised (timeouts are common).
@try{
proxy = [connection rootProxy];
}
@catch(id exception){
proxy = nil;
NSLog(@"caught exception \"%@\"", exception);
}
Your NSLog of proxy will likely crash since you didn't initialize
the local variable to nil, as well. Having netService as an ivar
assigned here doesn't make sense, either.
The method now looks like this:
And do you catch an exception when you send [connection rootProxy]?
Yes and no. When I set [connection setRequestTimeout: 10] and
[connection setReplyTimeout: 10] then I get a timeout exception.
However, when I don't, nothing appears to happen (I leave it running
for over 15 minutes just to make sure).
Finally, would it matter if I'm running the server and the client
on the same machine (localhost) over the network? I don't think it
should, but I'm wondering if it could be causing any problems.
Because I did notice that when, in the client, I did: NSLog
(@"service: %@", [netService hostName]); the value was (null).
If you were able to publish the service successfully, your client
probably hasn't resolved the service yet with -[NSNetService
resolveWithTimeout:]. You'll have to do that first, and then wait
for the delegate method to be called.
One thing I notice happening is that in my run log, I get this:
2006-06-29 16:02:07.356 Simple Client[891] Warning: -[NSNetService
resolve] is deprecated in Mac OS X 10.4. Please use -[NSNetService
resolveWithTimeout:]
I'm not sure what's causing that.
So I've now changed the structure of the code a little to implement
the delegate system. I set the service's delegate to be self. Now the
only thing that happens in connectToServer: is it tells the
netService to resolveWithTimeout. The rest of the code from that
method is moved to the delegate method netServiceDidResolveAddress
(which runs successfully). And yet, the application still hangs on
the same [connection rootProxy] line.
Also, check your firewall settings, and you might want to start
with something simple, like modifying the PictureSharing sample
code to use DO over Bonjour, just to make sure it works on your
machine.
I'll try doing that, too.
Thanks for all the help!
Robert Sesek
Email: email@hidden
www.iris-studios.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden