Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Intermittent message: [NSPortCoder sendBeforeTime:sendReplyPort:] timed out



Sorry if this post is a bit off-topic; I've posted the question at intervals of a few days to a few other forums that seemed more topical but have got no feedback. The issue in question relates to an app we're developing that uses Rendezvous for automatic discovery of a service based on Cocoa Distributed Objects, and perhaps someone here will have some insight.

Original post, slightly edited:

I'm getting the above message intermittently (less than 50% of the time - when if fails or works it will do so through several consecutive relaunches of the app) when trying to send messages to a remote object using Cocoa Distributed Objects.

If the warning message is familiar to anyone in a way that suggests a known problem and/or solution, I'd be very grateful for suggestions on what those might be. The code used to set up the receiving socket is shown below, followed by the code used to send the message:

-(void)setupSocket { // Set up the receiver's socket

  NSSocketPort *receivePort = nil;

  NS_DURING
    receivePort = [[NSSocketPort alloc] initWithTCPPort:SERVER_PORT];
  NS_HANDLER
    [receivePort release];
    receivePort = nil;
    NSLog(@"Error:  Failed to bind to TCP port");
  NS_ENDHANDLER

  if (receivePort!=nil) {

serverConnection = [[NSConnection alloc] initWithReceivePort:receivePort sendPort:nil];
[receivePort release];


[serverConnection setDelegate:self];
[serverConnection setRootObject:self];
[[NSRunLoop currentRunLoop] addPort:receivePort forMode:NSConnectionReplyMode];


// Set a flag so that we can reuse the port immediately after releasing the socket object

    {
      int socket = [receivePort socket];
      int flag = 1;

if (setsockopt(socket,SOL_SOCKET,SO_REUSEADDR,(void*)&flag,sizeof(flag)) < 0)
NSLog(@"Failed to set socket address reuse");


if (setsockopt(socket,SOL_SOCKET,SO_REUSEPORT,(void*)&flag,sizeof(flag)) < 0)
NSLog(@"Failed to set socket port reuse");
}
}
}



-(IBAction)launchTESTOnRemoteServer:(id)sender { // Sends a message to a remote object


  NSArray *selection = [serviceController selectedObjects];

  if (selection == nil || [selection count]==0) return;

  NSString *serverName = [[selection objectAtIndex:0] name];

  NSLog(@"Lauching TEST on %@",serverName);

NSSocketPort *sendPort = [[NSSocketPort alloc] initRemoteWithTCPPort:SERVER_PORT host:serverName];

serverConnection = [[NSConnection alloc] initWithReceivePort:nil sendPort:sendPort];
[sendPort release];


  id theProxy = [serverConnection rootProxy];

  NSNumber *val = [NSNumber numberWithFloat:7.5]; // Autoreleased

  [theProxy runTESTForClient:val];

}

I'm somewhat of a newbie at this stuff (DO, sockets, and Rendezvous), and have put this together from code fragments found various places. It's quite possible I'm not using the ports correctly. However it *does* work much of the time...

Thanks for any info,

Rick
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
_______________________________________________
rendezvous mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/rendezvous
Do not post admin requests to the list. They will be ignored.





Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.