• 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: NSPortCoder timed out, causes crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPortCoder timed out, causes crash


  • Subject: Re: NSPortCoder timed out, causes crash
  • From: Richard Salvatierra <email@hidden>
  • Date: Mon, 10 Sep 2007 13:23:24 -0400

I store all DO objects (client) in an array of dictionaries. This app runs in Master/Slave mode where the master will send commands to all known slaves. If a slave loses connection, I need to remove that from my array of known slaves so as to NOT try and send a message to that object. I need to know when a DO is no longer connected. Testing for [connection isValid] does not seem to help.


// connect to DO after netServiceDidResolveAddress passing object (dictionary)
- (BOOL) manualConnectObject:(NSDictionary*)object {
int port = [[object valueForKey:@"port"] intValue];
NSString *ipAddress = [object valueForKey:@"ip"];
NSSocketPort *sendPort = [[[NSSocketPort alloc] initRemoteWithTCPPort:port host:ipAddress] autorelease];
NSConnection *connection;

@try { connection = [NSConnection connectionWithReceivePort:nil sendPort:sendPort]; }
@catch (id theException) { NSLog(@"connection Exception: %@", theException); return NO; }
@finally{ /* do nothing */ }

[connection setReplyTimeout: TIMEOUT];
[connection setRequestTimeout: TIMEOUT];
[connection setDelegate:self];


	id remoteObject;
	remoteObject = [connection rootProxy];
	if(NULL != remoteObject){
		[object setValue: remoteObject forKey:@"remoteObject"];
		[object setValue: @"Connected" forKey: @"status"];
		[clientList reloadData];
		return YES;
	}
	return NO;
}

// when a command is triggered from within the Master...
- (IBAction) dispatchMethod:(id) object;
{
NSEnumerator * enumerator = [[clientListController arrangedObjects] objectEnumerator];
id remoteObject;
while(remoteObject = [enumerator nextObject]) {
// test for existence of distantObject for "remoteObject" dictionary value
id distantObject = [remoteObject valueForKey:@"remoteObject"];
if(nil == distantObject) continue;


@try {
[[remoteObject valueForKey:@"remoteObject"] dispatchMethodFromDictionary: object];
}
@catch (id theException) {
NSLog(@"%@", theException);
[remoteObject removeObjectForKey: @"remoteObject"];
[remoteObject setValue: @"Error" forKey: @"status"];
}
@finally { }
}
}





_______________ Richard Salvatierra 678.438.4592 [mobile] 770.992.4004 [home]

On Sep 10, 2007, at 12:24 PM, Shawn Erickson wrote:

On 9/10/07, Richard Salvatierra <email@hidden> wrote:
I have a server/client test app using DO that sends the client values
over a local network. If the client connection fails (the app quits/
crashes/unplugged, etc.) and the server sends the client another
message, the server app logs a [NSPortCoder
sendBeforeTime:sendReplyPort:] timed out.  Now, while running in
xCode, the run log displays the time out message. If running the app
outside of xCode, it crashes. The hard part is the crash does not
create a crash log. Before I send the message to the DO, I Try/Catch.
What causes the crash.

@try {
        [remoteObject sendDictionary: object];
}
@catch (id theException) {
        NSLog(@"%@", theException);
        [remoteObject release];
}
@finally { }

Are you over releasing and/or attempting to use a dealloced reference to remoteObject. It seems a little strange that you would release the remote object in the case of an exception yet not in the normal case (aka under @finally).

Anyway if it doesn't produce a crash log then likely the application
decided to abort (or exit early). This could imply that an exception
isn't be handled.

Anything in the console log when you run the application?

-Shawn

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSPortCoder timed out, causes crash (From: Richard Salvatierra <email@hidden>)
 >Re: NSPortCoder timed out, causes crash (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: characters in cocoa
  • Next by Date: Re: custom view won't update
  • Previous by thread: Re: NSPortCoder timed out, causes crash
  • Next by thread: SOLVED: Using the tab key to cycle through custom NSViews?
  • Index(es):
    • Date
    • Thread