DO help
DO help
- Subject: DO help
- From: Lloyd Dupont <email@hidden>
- Date: Fri, 30 May 2003 16:12:28 +1000
I have DO server which I could start and stop (it register in
Rendezvous & NSPortNameServer).
however there is some weird behavior which I don't understand.
one of these strange behavior (which I clearly identify) is the
following:
if my server 'unregister' (mean it close its NSConnection, remove
itself from rendezvous & NSPortNameServer) but doesn't quit, when a
client try to connect it, it hang. Whereas if I quit the server, the
client return an error immediately, any though ?
below is my register/unregister code:
/
/-----------------------------------------------------------------------
-------------------------------------
- (BOOL) registerServer
{
if(port < 0) {
NSConnection * conn = [NSConnection defaultConnection];
[conn setRootObject: self];
return [conn registerName: name];
}
else {
if(connection) // already registered
return TRUE;
NSSocketPort *sport = [[[NSSocketPort alloc]
initWithTCPPort:port] autorelease];
if([[NSSocketPortNameServer sharedInstance] registerPort:sport
name:name]
== NO) {
IHLog("registerPort failed: %s", currenterror());
return FALSE;
}
connection = [[NSConnection alloc] initWithReceivePort:sport
sendPort:nil];
[connection setRootObject:self];
const struct sockaddr_in * sai = (const struct sockaddr_in *)
[[sport address] bytes];
int realport = ntohs(sai->sin_port);
service = [RendezvousHelper publish:name
port:realport
ofType:type];
[service retain];
return TRUE;
}
}
- (void) unregister
{
if(port < 0) {
NSConnection * conn = [NSConnection defaultConnection];
[conn setRootObject: nil];
[conn registerName:nil];
}
else
[[NSSocketPortNameServer sharedInstance]
removePortForName:name];
[service stop];
[service release];
service = nil;
[connection release];
connection = nil;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.