Hack for people with machines without IP addresses

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3834 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-03-02 15:43:33 +00:00
parent f510382553
commit 241d282ac9
2 changed files with 17 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 2 15:07:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/TcpPort.m: If the host has no IP address, try finding the
address of 'localhost' and, if that fails, use 127.0.0.1
Tue Mar 2 11:25:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* NSTimeZones/Makefile.postamble: Updated to preserver old localtime

View file

@ -1200,9 +1200,18 @@ static NSMapTable* port_number_2_port;
}
hp = gethostbyname (hostname);
if (!hp)
[self error: "Could not get address of local host \"%s\"", hostname];
NSAssert(hp, NSInternalInconsistencyException);
memcpy (&(p->_listening_address.sin_addr), hp->h_addr, hp->h_length);
hp = gethostbyname ("localhost");
if (hp == 0)
{
NSLog(@"Unable to get IP address of '%s' or of 'localhost'", hostname);
#ifndef HAVE_INET_ATON
p->_listening_address.sin_addr.s_addr = inet_addr("127.0.0.1");
#else
inet_aton("127.0.0.1", &p->_listening_address.sin_addr.s_addr);
#endif
}
else
memcpy (&(p->_listening_address.sin_addr), hp->h_addr, hp->h_length);
}
/* Set it up to accept connections, let 10 pending connections queue */