From b30aa658d7b4d946427119b23cfc264cc7172149 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 Feb 2011 16:33:29 -0800 Subject: connect.c: disable AI_NUMERICSERV It's not needed since we already verify the service is a numeric port. AI_NUMERICSERV is not available in older glibc (<2.3.4) and probably other old systems. --- ext/kgio/connect.c | 2 +- test/test_tcp_connect.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/kgio/connect.c b/ext/kgio/connect.c index 1545853..8a91ea2 100644 --- a/ext/kgio/connect.c +++ b/ext/kgio/connect.c @@ -73,7 +73,7 @@ static VALUE tcp_connect(VALUE klass, VALUE ip, VALUE port, int io_wait) hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; /* disallow non-deterministic DNS lookups */ - hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV; + hints.ai_flags = AI_NUMERICHOST; rc = getaddrinfo(ipname, ipport, &hints, &res); if (rc != 0) diff --git a/test/test_tcp_connect.rb b/test/test_tcp_connect.rb index 194a630..4fb4070 100644 --- a/test/test_tcp_connect.rb +++ b/test/test_tcp_connect.rb @@ -44,6 +44,8 @@ class TestKgioTcpConnect < Test::Unit::TestCase def test_tcp_socket_new_invalid assert_raises(ArgumentError) { Kgio::TCPSocket.new('example.com', 80) } assert_raises(ArgumentError) { Kgio::TCPSocket.new('999.999.999.999', 80) } + assert_raises(TypeError) { Kgio::TCPSocket.new("127.0.0.1", "http") } + assert_raises(TypeError) { Kgio::TCPSocket.new('example.com', "http") } end def test_tcp_socket_new -- cgit v1.2.3-24-ge0c7