Use inet_aton() where available

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5247 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-11-21 06:39:35 +00:00
parent afd31237b9
commit c5d0bc1683
2 changed files with 9 additions and 2 deletions

View file

@ -6,6 +6,7 @@ Sun Nov 21 6:35:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/UnixFileHandle.m: ([-availableData]) fixed to block when no
data is availabvle on a comms channel - as per spec. This bug was
also reported by Dan <dan@services.iirux.ro>
* Source/NSHost.m: Use inet_aton() if available.
1999-11-18 Adam Fedor <fedor@gnu.org>

View file

@ -204,12 +204,18 @@ static NSMutableDictionary*_hostCache = nil;
NSLog(@"Nil address sent to +[NSHost hostWithAddress]");
return nil;
}
hostaddr.s_addr = inet_addr((char*)[address cString]);
#ifndef HAVE_INET_ATON
hostaddr.s_addr = inet_addr([address cString]);
if (hostaddr.s_addr == -1)
{
return nil;
}
#else
if (inet_aton([address cString], &hostaddr.s_addr) == 0)
{
return nil;
}
#endif
h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET);
return [self _hostWithHostEntry: h];