• 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
Intermittent message: [NSPortCoder sendBeforeTime:sendReplyPort:] timed out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: Intermittent message: [NSPortCoder sendBeforeTime:sendReplyPort:] timed out
  • From: Rick Hoge <email@hidden>
  • Date: Tue, 13 Jul 2004 19:17:25 -0400

I'm getting the above message intermittently (50% of the time, with repeated runs of success or failure) when trying to send messages to a remote object using distributed objects. 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 a complete newbie at this stuff, 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.


  • Prev by Date: Re: Newbie Question
  • Next by Date: Re: Wise? Stupid? Somewhere in between? Thinkin' out loud...
  • Previous by thread: Re: Newbie Question
  • Next by thread: Newbie Question follow up
  • Index(es):
    • Date
    • Thread