• 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: Distributed Objects and Bonjour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distributed Objects and Bonjour


  • Subject: Re: Distributed Objects and Bonjour
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Wed, 28 Jun 2006 18:22:46 -0700


On Jun 28, 2006, at 07:54, Robert Sesek wrote:


On Jun 28, 2006, at 7:12 AM, Adam R. Maxwell wrote:

On Jun 26, 2006, at 11:37, Robert Sesek wrote:


TI can broadcast and browse my Bonjour service and I setup my D-O system like this:



[...]
The method now looks like this:

- (void)startDistributedObject
{
	connection = [[NSConnection connectionWithReceivePort: socket
												sendPort: nil] retain];
	[connection setRootObject: [[manager dbConnector] retain]];
	[[NSSocketPortNameServer sharedInstance] registerPort: socket
													 name: @"TindexServer"];
}

Now you're leaking [manager dbConnector].

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]?

[...]

Thanks for the example! I've been comparing your code to mine and they're almost identical. The only thing that's different is that you use NSPort's instead of NSSocketPorts for the server and that you establish (in the D-O setup) a NSConnection (using + [NSConnection connectionWithReceivePort: sendPort]) both a sending and receiving port, while I only use a receiving port. Would this be causing a problem as the server cannot send replies?

We use NSPorts for communication between threads. An NSSocketPort is used for communication between hosts (BDSKSharingServer <-> BDSKSharedGroupServer).


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.


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.

Adam

_______________________________________________
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


  • Follow-Ups:
    • Re: Distributed Objects and Bonjour
      • From: Robert Sesek <email@hidden>
References: 
 >Distributed Objects and Bonjour (From: Robert Sesek <email@hidden>)
 >Re: Distributed Objects and Bonjour (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: Re: Implementing a TCP port listener in Cocoa
  • Next by Date: Re: Implementing a TCP port listener in Cocoa
  • Previous by thread: Re: Distributed Objects and Bonjour
  • Next by thread: Re: Distributed Objects and Bonjour
  • Index(es):
    • Date
    • Thread