Include netdb.h to detect getaddrinfo. Work around problem with getaddrinfo

not properly processing numeric IPv4 addresses. Fixes V5.1 part of #472675.
This commit is contained in:
Martin v. Löwis 2001-10-24 14:36:00 +00:00
parent 6bc55c435a
commit 861a65bc2f
3 changed files with 361 additions and 369 deletions

View file

@ -622,6 +622,12 @@ setipaddr(char* name, struct sockaddr * addr_ret, int af)
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
error = getaddrinfo(name, NULL, &hints, &res);
if (error = EAI_NONAME && af == AF_UNSPEC) {
/* On OSF/1 V5.1, numeric-to-addr conversion
fails if no address family is given. Assume IPv4 for now.*/
hints.ai_family = AF_INET;
error = getaddrinfo(name, NULL, &hints, &res);
}
if (error) {
PyGAI_Err(error);
return -1;