diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-06 13:28:23 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-06 13:28:23 +0000 |
commit | 175f3b2d7aa6426bb36943cbf13fb1bf40d017bb (patch) | |
tree | bec982d620d8068b0c20d2319cff78b93f645f0d /ext | |
parent | fb019df11e175e350cfd8f108da0be427e205eb5 (diff) | |
download | ruby-175f3b2d7aa6426bb36943cbf13fb1bf40d017bb.tar.gz |
use numerichost if cannot resolve hostname
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/socket.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 9e1d705521..f34b74b340 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -750,14 +750,14 @@ ipaddr(sockaddr, norevlookup) family = rb_str_new2(pbuf); break; } - + + addr1 = Qnil; if (!norevlookup) { error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf), NULL, 0, 0); - if (error) { - raise_socket_error("getnameinfo", error); + if (! error) { + addr1 = rb_str_new2(hbuf); } - addr1 = rb_str_new2(hbuf); } error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV); @@ -765,7 +765,7 @@ ipaddr(sockaddr, norevlookup) raise_socket_error("getnameinfo", error); } addr2 = rb_str_new2(hbuf); - if (norevlookup) { + if (addr1 == Qnil) { addr1 = addr2; } port = INT2FIX(atoi(pbuf)); |