Fall back on default port number if necessary.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3324 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-11-25 19:30:01 +00:00
parent fce2236920
commit 935d88e101

View file

@ -789,11 +789,51 @@ static NSPortNameServer *defaultServer = nil;
hostname = @"localhost";
}
expecting = 1;
handle = [NSFileHandle fileHandleAsClientInBackgroundAtAddress: host
NS_DURING
{
handle = [NSFileHandle fileHandleAsClientInBackgroundAtAddress: host
service: serverPort
protocol: @"tcp"
forModes: modes];
}
NS_HANDLER
{
if ([[localException name] isEqual: NSInvalidArgumentException])
{
NSLog(@"Exception looking up port for gdomap - %@\n", localException);
handle = nil;
}
else
{
[localException raise];
}
}
NS_ENDHANDLER
if (handle == nil)
{
NSLog(@"Failed to find gdomap port with name '%@',\nperhaps your "
@"/etc/services file is not correctly set up?\n"
@"Retrying with default (IANA allocated) port number 538",
serverPort);
NS_DURING
{
handle = [NSFileHandle fileHandleAsClientInBackgroundAtAddress: host
service: @"538"
protocol: @"tcp"
forModes: modes];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
if (handle)
{
[serverPort release];
serverPort = @"538";
}
}
if (handle == nil)
{
@ -802,6 +842,7 @@ static NSPortNameServer *defaultServer = nil;
hostname];
}
expecting = 1;
[handle retain];
[NSNotificationCenter addObserver: self
selector: @selector(_didConnect:)