diff --git a/ChangeLog b/ChangeLog index e83bb8935..1136736b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-07-15 Richard Frith-Macdonald + + * Source/NSDistributedNotificationCenter.m: Use loopback network + interface for local center. + * Tools/gdnc.m: ditto. + 2003-07-11 David Ayers * Source/GNUmakefile: Make GNUstep.h public. diff --git a/Source/NSDistributedNotificationCenter.m b/Source/NSDistributedNotificationCenter.m index 15544b9f5..2d7cf996d 100644 --- a/Source/NSDistributedNotificationCenter.m +++ b/Source/NSDistributedNotificationCenter.m @@ -566,7 +566,7 @@ static NSDistributedNotificationCenter *netCenter = nil; stringForKey: @"NSHost"]; if (host == nil) { - host = @""; + host = @"localhost"; } else { @@ -593,7 +593,9 @@ static NSDistributedNotificationCenter *netCenter = nil; host = [h name]; } } - if ([host length] == 0) + if ([host length] == 0 + || [host isEqualToString: @"localhost"] == YES + || [host isEqualToString: @"127.0.0.1"] == YES) { description = @"local host"; } diff --git a/Tools/gdnc.m b/Tools/gdnc.m index 834abe307..800eeeea8 100644 --- a/Tools/gdnc.m +++ b/Tools/gdnc.m @@ -34,6 +34,8 @@ #define NSIG 32 #endif +@class GSTcpPort; + static void ihandler(int sig) { @@ -300,14 +302,13 @@ ihandler(int sig) { NSString *hostname; NSString *service = GDNC_SERVICE; + BOOL isLocal = NO; connections = NSCreateMapTable(NSObjectMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0); allObservers = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, 0); observersForNames = [NSMutableDictionary new]; observersForObjects = [NSMutableDictionary new]; - conn = [NSConnection defaultConnection]; - [conn setRootObject: self]; if ([[NSUserDefaults standardUserDefaults] boolForKey: @"GSNetwork"] == YES) { @@ -315,6 +316,32 @@ ihandler(int sig) } hostname = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"]; if ([hostname length] == 0 + || [hostname isEqualToString: @"localhost"] == YES + || [hostname isEqualToString: @"127.0.0.1"] == YES) + { + isLocal = YES; + } + + /* + * If this is the local server for the current host, + * use the loopback network interface. Otherwise + * create a public connection. + */ + if (isLocal == YES && service != GDNC_NETWORK) + { + NSPort *port = [GSTcpPort portWithNumber: 0 + onHost: [NSHost localHost] + forceAddress: @"127.0.0.1" + listener: YES]; + conn = [[NSConnection alloc] initWithReceivePort: port sendPort: nil]; + } + else + { + conn = [NSConnection defaultConnection]; + } + [conn setRootObject: self]; + + if (isLocal == YES || [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES) { if ([conn registerName: service] == NO)