summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/extmk.rb.in25
-rw-r--r--ext/extmk.rb.nt403
-rw-r--r--ext/socket/addrinfo.h8
-rw-r--r--ext/socket/extconf.rb30
-rw-r--r--ext/socket/getaddrinfo.c2
-rw-r--r--ext/socket/getnameinfo.c2
-rw-r--r--ext/socket/socket.c207
7 files changed, 363 insertions, 314 deletions
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index db34b4252d..f98ca4dc2b 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -71,8 +71,8 @@ CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
else
CFLAGS = "@CFLAGS@"
end
-LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c @LIBS@ %s"
-CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s conftest.c"
+LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
+CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c"
if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
$null = open("nul", "w")
@@ -98,7 +98,7 @@ def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
end
def try_link(src, opt="")
@@ -109,23 +109,23 @@ def try_link(src, opt="")
end
end
-def try_cpp(src, opt=$CFLAGS)
+def try_cpp(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
- xsystem(format(CPP, opt))
+ xsystem(format(CPP, $CFLAGS, opt))
ensure
system "rm -f conftest*"
end
end
-def egrep_cpp(pat, src, opt=$CFLAGS)
+def egrep_cpp(pat, src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, opt))
ensure
system "rm -f conftest*"
end
@@ -268,7 +268,7 @@ def arg_config(config, default=nil)
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
@@ -283,7 +283,7 @@ def with_config(config, default=nil)
end
def enable_config(config, default=nil)
- if arg_config("--enable-"+config, true)
+ if arg_config("--enable-"+config, default)
true
elsif arg_config("--disable-"+config, false)
false
@@ -335,6 +335,7 @@ srcdir = #{$srcdir}
VPATH = #{$srcdir}
hdrdir = #{$topdir}
+DESTDIR =
CC = @CC@
@@ -360,7 +361,7 @@ ruby_inc = #{$ruby_inc}
#### End of system configuration section. ####
"
- mfile.printf "LOCAL_LIBS = %s\n", $local_libs unless $local_libs == ""
+ mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
@@ -472,7 +473,7 @@ def extmake(target)
$objs = nil
$libs = PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? nil : "-lc"
- $local_libs = "" # to be assigned in extconf.rb
+ $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
@@ -509,7 +510,7 @@ def extmake(target)
$extlibs ||= ""
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs
- $extlibs += " " + $local_libs unless $local_libs == ""
+ $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
system "rm -f conftest*"
diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt
index 81bbb3e4dd..b5aa4592c2 100644
--- a/ext/extmk.rb.nt
+++ b/ext/extmk.rb.nt
@@ -3,39 +3,39 @@
$".push 'mkmf.rb'
if ARGV[0] == 'static'
- $force_static = TRUE
+ $force_static = true
ARGV.shift
elsif ARGV[0] == 'install'
- $install = TRUE
+ $install = true
$destdir = ARGV[1] || ''
ARGV.shift
elsif ARGV[0] == 'clean'
- $clean = TRUE
+ $clean = true
ARGV.shift
end
$extlist = []
-$cache_mod = FALSE;
+$cache_mod = false;
$lib_cache = {}
$func_cache = {}
$hdr_cache = {}
-$top_srcdir = ".."
-if $top_srcdir !~ "^/"
- # get absolute path
- $top_srcdir = File.expand_path($top_srcdir)
-end
+
+$top_srcdir = File.expand_path("..")
$topdir = File.expand_path("..")
$topdir = File.expand_path($topdir)
$ruby_inc = $top_srcdir
load "#{$top_srcdir}/lib/find.rb"
+#$dllopt = '-MD'
+$dllopt = ''
+
if File.exist?("config.cache") then
f = open("config.cache", "r")
while f.gets
case $_
- when /^lib: (.+) (yes|no)/
+ when /^lib: ([\w_]+) (yes|no)/
$lib_cache[$1] = $2
when /^func: ([\w_]+) (yes|no)/
$func_cache[$1] = $2
@@ -59,11 +59,11 @@ def older(file1, file2)
return false
end
-CFLAGS = "-g -O2"
-LINK = "gcc -o conftest -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s %s conftest.c -ldl -lcrypt -lm %s"
-CPP = "gcc -E -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s conftest.c"
-
+#LINK = "cl -o conftest.exe -I../.. -Zi -O -I. %s conftest.c %s > nul"
+LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s > nul"
+CPP = "cl -E -I../.. -I../../missing -I../../win32 -I. -Zi -O %s conftest.c > nul"
$null = open("nul", "w")
+
$orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
@@ -78,12 +78,18 @@ def xsystem command
return r
end
-def try_link(src, opt="")
+def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+end
+
+def try_link(src, opt="")
begin
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ try_link0(src, opt)
+ ensure
+ system "rm -f conftest*"
end
end
@@ -91,19 +97,27 @@ def try_cpp(src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP, opt))
+ begin
+ xsystem(format(CPP, opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def egrep_cpp(pat, src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ begin
+ xsystem(format(CPP+"|egrep #{pat}", opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def try_run(src, opt="")
begin
- if try_link(src, opt)
+ if try_link0(src, opt)
if xsystem("./conftest")
true
else
@@ -112,6 +126,8 @@ def try_run(src, opt="")
else
nil
end
+ ensure
+ system "rm -f conftest*"
end
end
@@ -134,73 +150,84 @@ def install_rb(mfile)
end
def have_library(lib, func="main")
+ #print format("have_library(%s, %s)\n", lib, func)
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
if $libs
- $libs = "-l" + lib + " " + $libs
+ $libs = lib + ".lib " + $libs
else
- $libs = "-l" + lib
+ $libs = lib + ".lib "
end
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
if func && func != ""
if $libs
- libs = "-l" + lib + " " + $libs
+ libs = lib + ".lib " + $libs
else
- libs = "-l" + lib
+ libs = lib + ".lib"
end
+ #print "libs=#{libs}\n"
unless try_link(<<"SRC", libs)
+#include <windows.h>
+#include <winsock.h>
+//char #{func}();
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+ #print "fail : #{libs}\n"
$lib_cache[lib] = 'no'
- $cache_mod = TRUE
- return FALSE
- end
- else
- if $libs
- libs = "-l" + lib + " " + $libs
- else
- libs = "-l" + lib
+ $cache_mod = true
+ return false
end
end
$libs = libs
$lib_cache[lib] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_func(func)
if $func_cache[func]
if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
+ cfile = open("conftest.c", "w")
+ cfile.printf "\
+#include <windows.h>
+#include <winsock.h>
+//char %s();
+int main() { return 0; }
+int t() { %s(); return 0; }
+", func, func
+ cfile.close
+
libs = $libs
libs = "" if libs == nil
- unless try_link(<<"SRC", libs)
-char #{func}();
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- $func_cache[func] = 'no'
- $cache_mod = TRUE
- return FALSE
+ begin
+ #print "libs=#{libs}\n"
+ unless try_link(libs)
+ $func_cache[func] = 'no'
+ $cache_mod = true
+ return false
+ end
+ ensure
+ system "rm -f conftest*"
end
$defs.push(format("-DHAVE_%s", func.upcase))
$func_cache[func] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_header(header)
@@ -208,9 +235,9 @@ def have_header(header)
if $hdr_cache[header] == "yes"
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
@@ -218,25 +245,25 @@ def have_header(header)
#include <#{header}>
SRC
$hdr_cache[header] = 'no'
- $cache_mod = TRUE
- return FALSE
+ $cache_mod = true
+ return false
end
$hdr_cache[header] = 'yes'
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def arg_config(config, default=nil)
unless defined? $configure_args
$configure_args = {}
- for arg in " --prefix=/usr --with-dbm-include=/usr/include/db1".split
+ for arg in ENV["CONFIGURE_ARGS"].split
next unless /^--/ =~ arg
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
@@ -273,121 +300,96 @@ end
def create_makefile(target)
- if $libs and "so" == "o"
+ if $libs
libs = $libs.split
for lib in libs
- lib.sub!(/-l(.*)/, '"lib\1.a"')
+ lib.sub!(/(.*)/, '"\1.lib"') if /.lib$/ !~ lib
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
+ $libs = "" unless $libs
- $DLDFLAGS = ''
-
- if PLATFORM =~ /beos/
- if $libs
- $libs = $libs + " -lruby"
- else
- $libs = "-lruby"
- end
- $DLDFLAGS = $DLDFLAGS + " -L" + $topdir
- end
-
- $srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.printf "\
-SHELL = /bin/sh
+SHELL = $(COMPSEC)
#### Start of system configuration section. ####
-srcdir = #{$srcdir}
+srcdir = .
+VPATH = .
-hdrdir = #{$topdir}
+CC = cl
-CC = gcc
+CFLAGS = %s -I../.. -I../../missing -I../../win32 -I. -O -DNT %s #{CFLAGS} #$CFLAGS %s
-prefix = /usr
-CFLAGS = %s -I#{$topdir} -I#{$top_srcdir} -I${prefix}/include #{CFLAGS} #$CFLAGS %s
-DLDFLAGS = #$DLDFLAGS #$LDFLAGS
-LDSHARED = gcc -shared
-", if $static then "" else "-fPIC" end, $defs.join(" ")
+RUBYLIB = ../../ruby.lib
+DLDFLAGS = /DLL
+LDSHARED =
+", if $static then "" else "-fpic" end, $dllopt, $defs.join(" ")
- mfile.printf "\
+ if $force_static
+ print "static\n"
+ else
+ print "non static\n"
+ end
-RUBY_INSTALL_NAME = ruby
+ mfile.printf "\
-prefix = /usr
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-pkglibdir = $(libdir)/ruby/1.3
-archdir = $(pkglibdir)/i586-linux
-ruby_inc = #{$ruby_inc}
+libdir = /usr/local/lib/ruby/i386-mswin32
#### End of system configuration section. ####
-
"
- mfile.printf "LOCAL_LIBS = %s\n", $local_libs unless $local_libs == ""
+ mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
- $objs = []
- for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{c,cc}"]
- f = File.basename(f)
- f.sub!(/\.(c|cc)$/, ".o")
- $objs.push f
+ $objs = Dir["*.{c,cc}"]
+ for f in $objs
+ f.sub!(/\.(c|cc)$/, ".obj")
end
end
mfile.printf $objs.join(" ")
mfile.printf "\n"
- mfile.printf <<EOS
-TARGET = #{target}
-DLLIB = $(TARGET).#{$static ? "a" : "so"}
-
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-
-binsuffix =
+ mfile.printf "\
+TARGET = %s
+DLLIB = $(TARGET).%s
+INSTALL = ginstall -c
+DEFFILE = %s.def
-all: $(DLLIB)
+all: $(DLLIB)
-clean:; @rm -f *.o *.a *.so *.sl *.a
+clean:; @rm -f *.obj *.lib *.exp vc*.pdb *.bak *.def
@rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(binsuffix) *~
-realclean: clean
-EOS
-
- mfile.printf <<EOS
+realclean: clean
install:
@test -d $(DESTDIR)$(libdir) || mkdir $(DESTDIR)$(libdir)
@test -d $(DESTDIR)$(pkglibdir) || mkdir $(DESTDIR)$(pkglibdir)
@test -d $(DESTDIR)$(archdir) || mkdir $(DESTDIR)$(archdir)
-EOS
+", target,
+ if $force_static then "lib" else "dll" end, target
+
if !$static
mfile.printf "\
- $(INSTALL) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
+ $(INSTALL) $(DLLIB) $(libdir)/$(DLLIB)
"
end
- install_rb(mfile)
- mfile.printf "\n"
- if $static
- mfile.printf "\
-$(DLLIB): $(OBJS)
- ar cru $(DLLIB) $(OBJS)
- @-ranlib $(DLLIB) 2> /dev/null || true
-"
- else
+ if $force_static
mfile.printf "\
$(DLLIB): $(OBJS)
- $(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
+ lib /OUT:$(DLLIB) $(OBJS)
"
- elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
+ else
mfile.printf "\
-$(DLLIB): $(OBJS)
- ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)
+$(DEFFILE):
+ echo $(DEFFILE)
+
+$(DLLIB): $(OBJS) $(DEFFILE)
+ cl -DLL -o$(DLLIB) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
"
end
@@ -400,99 +402,120 @@ $(DLLIB): $(OBJS)
dfile.close
end
mfile.close
-
+ if $static
+ #printf format("push %s,%s\n", $static, target); ##debug print##
+ $extlist.push [$static,target]
+ end
+end
+
+#template of .def file.
+def create_def(basename)
+ defname = sprintf("%s.def", basename)
+ f = open(defname, "w")
+ f.printf "\
+LIBRARY %s.dll
+CODE LOADONCALL
+DATA LOADONCALL
+DESCRIPTION 'win32 %s.dll'
+EXPORTS
+
+ Init_%s
+", basename, basename, basename
+ f.close
+
end
def extmake(target)
if $force_static or $static_ext[target]
$static = target
else
- $static = FALSE
+ $static = false
end
return if $nodynamic and not $static
- $objs = nil
- $libs = "-lc"
- $local_libs = "" # to be assigned in extconf.rb
+ $CFLAGS = nil
+ $LDFLAGS = nil
+ $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
begin
- system "mkdir", target unless File.directory?(target)
Dir.chdir target
- $mdir = target
if $static_ext.size > 0 ||
!File.exist?("./Makefile") ||
- older("./Makefile", "#{$top_srcdir}/ext/Setup") ||
+ older("./Makefile", "../Setup") ||
older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
+ older("./Makefile", "./extconf.rb")
then
$defs = []
- if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
- load "#{$top_srcdir}/ext/#{target}/extconf.rb"
+ if File.exist?("extconf.rb")
+ load "extconf.rb"
else
create_makefile(target);
end
end
+
+ if !File.exist?("#{target}.def")
+ create_def(target)
+ end
+
if File.exist?("./Makefile")
- if $static
- $extlist.push [$static,target]
- end
if $install
- system "make install DESTDIR=#{$destdir}"
+ system "nmake install DESTDIR=#{$destdir}"
+ if File.directory? "./lib"
+ for i in Dir["./lib/*.rb"]
+ system "ginstall -c #{i} /usr/local/lib/ruby/i386-mswin32"
+ end
+ end
elsif $clean
- system "make clean"
+ system "nmake clean"
else
- system "make all" or exit
+ #print "!!!make!!!\n"
+ system "nmake all"
end
end
if $static
- $extlibs ||= ""
+ $extlibs = " "
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs
- $extlibs += " " + $local_libs unless $local_libs == ""
+ $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
- system "rm -f conftest*"
Dir.chdir ".."
end
end
# get static-link modules
$static_ext = {}
-for setup in ["Setup", "#{$top_srcdir}/ext/Setup"]
- if File.file? setup
- f = open(setup)
- while f.gets()
- $_.chomp!
- sub!(/#.*$/, '')
- next if /^\s*$/
- if /^option +nodynamic/
- $nodynamic = TRUE
- next
- end
- $static_ext[$_.split[0]] = TRUE
+if File.file? "./Setup"
+ f = open("./Setup")
+ while f.gets()
+ $_.chop!
+ sub!(/#.*$/, '')
+ next if /^\s*$/
+ #print $_, "\n"
+
+ if /^option +nodynamic/
+ $nodynamic = true
+ next
end
- f.close
- break
+ $static_ext[$_.split[0]] = true
end
+ f.close
end
-for d in Dir["#{$top_srcdir}/ext/*"]
+for d in Dir["*"]
File.directory?(d) || next
File.file?(d + "/MANIFEST") || next
- d = File.basename(d)
+ d = $1 if d =~ /\/([\/]*)$/
if $install
print "installing ", d, "\n"
elsif $clean
print "cleaning ", d, "\n"
else
print "compiling ", d, "\n"
- if PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
- load "#{$top_srcdir}/ext/aix_mksym.rb"
- end
end
extmake(d)
end
@@ -512,64 +535,62 @@ if $cache_mod
end
exit if $install or $clean
-$extinit = "" unless $extinit
-
-ruby = "ruby"
-miniruby = "miniruby"
-
+$extinit = " " unless $extinit
+$extobjs = ""
if $extlist.size > 0
for s,t in $extlist
- f = format("%s/%s.a", s, t)
- if File.exist?(f)
+ #for s,t in $static_ext
+ #f = format("%s/%s.obj", s, t)
+ #f = format("%s/%s.obj", s, s)
+ l = format("%s/%s.lib", s, s)
+ if File.exist?(l)
$extinit += format("\
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
-", t, t)
- $extobjs = "" unless $extobjs
+", s, s)
$extobjs += "ext/"
- $extobjs += f
+ #$extobjs += f # *.obj
+ $extobjs += l # *.lib
$extobjs += " "
else
- FALSE
+ false
end
end
- if older("extinit.c", "#{$top_srcdir}/ext/Setup")
+ if older("extinit.c", "Setup")
f = open("extinit.c", "w")
f.printf "void Init_ext() {\n"
f.printf $extinit
f.printf "}\n"
f.close
end
- if older("extinit.o", "extinit.c")
- cmd = "gcc " + CFLAGS + " -c extinit.c"
+ if older("extinit.obj", "extinit.c")
+ cmd = "cl -Zi -O -I. -c extinit.c"
print cmd, "\n"
system cmd or exit 1
end
Dir.chdir ".."
- if older(ruby, "#{$top_srcdir}/ext/Setup") or older(ruby, miniruby)
- system("rm -f #{ruby}")
+ if older("ruby.exe", "ext/Setup") or older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
end
- if $extobjs
- $extobjs = "ext/extinit.o " + $extobjs
- else
- $extobjs = "ext/extinit.o "
- end
- if PLATFORM =~ /m68k-human|beos/
- $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
- end
- system format(%[make #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs)
+ $extobjs = "ext/extinit.obj " + $extobjs
+ #$extlibs = ""
+ #print "EXTLIBS=#{$extlibs}\n"
+ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
+ $extlibs.gsub!(" +", " ") if $extlibs
+ #print "EXTLIBS=#{$extlibs}\n"
+
+ system format('nmake ruby.exe EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
else
Dir.chdir ".."
- if older(ruby, miniruby)
- system("rm -f #{ruby}")
- system("make #{ruby}")
+ if older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
+ `cp miniruby.exe ruby.exe`
end
end
-
#Local variables:
# mode: ruby
#end:
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index 1236437897..5d2c7dea45 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -66,7 +66,7 @@
#define freeaddrinfo freeaddrinfo__compat
#ifndef __P
-# ifdef HAVE_PROTOTYPES 1
+# ifdef HAVE_PROTOTYPES
# define __P(args) args
# else
# define __P(args)
@@ -136,12 +136,6 @@ struct addrinfo {
struct addrinfo *ai_next; /* next structure in linked list */
};
-struct sockaddr_storage {
- u_int8_t __ss_len;
- u_int8_t __ss_family;
- u_int8_t fill[126];
-};
-
extern int getaddrinfo __P((
const char *hostname, const char *servname,
const struct addrinfo *hints,
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 12b24667b4..0526e319ec 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -21,17 +21,13 @@ else
end
$ipv6 = false
-if enable_config("ipv6", true)
- if try_run(<<EOF)
+if enable_config("ipv6", false)
+ if try_link(<<EOF)
#include <sys/types.h>
#include <sys/socket.h>
main()
{
- exit(0);
- if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
- exit(1);
- else
- exit(0);
+ socket(AF_INET6, SOCK_STREAM, 0);
}
EOF
$CFLAGS+=" -DENABLE_IPV6"
@@ -39,7 +35,6 @@ EOF
end
end
-
$ipv6type = nil
$ipv6lib = nil
$ipv6libdir = nil
@@ -101,9 +96,10 @@ EOF
if $ipv6lib
if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a"
- $LDFLAGS += " -L#$ipv6libdir -l#$ipv6lib"
+ $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib"
else
print <<EOS
+
Fatal: no #$ipv6lib library found. cannot continue.
You need to fetch lib#{$ipv6lib}.a from appropriate
ipv6 kit and compile beforehand.
@@ -235,13 +231,21 @@ main()
EOF
$getaddr_info_ok = true
end
+if $ipv6 and not $getaddr_info_ok
+ print <<EOS
+
+Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
+But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
+you cannot compile IPv6 socket classes with broken these functions.
+EOS
+ exit
+end
+
$objs = ["socket.o"]
-if $getaddr_info_ok
- if have_func("getaddrinfo") and have_func("getnameinfo")
- have_getaddrinfo = true
- end
+if $getaddr_info_ok and have_func("getaddrinfo") and have_func("getnameinfo")
+ have_getaddrinfo = true
end
if have_getaddrinfo
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index 64d29b17ab..cdc3de52e4 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -221,7 +221,7 @@ inet_pton(af, hostname, pton)
struct in_addr in;
#ifdef HAVE_INET_ATON
- if (!inet_aton(hostname, &in.s_addr))
+ if (!inet_aton(hostname, &in))
return 0;
#else
int d1, d2, d3, d4;
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index e4a57c6554..89245d324f 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -93,7 +93,7 @@ inet_ntop(af, addr, numaddr, numaddr_len)
#ifdef HAVE_INET_NTOA
struct in_addr in;
memcpy(&in.s_addr, addr, sizeof(in.s_addr));
- strncpy(numaddr, numaddr_len, inet_ntoa(in));
+ snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
#else
unsigned long x = ntohl(*(unsigned long*)addr);
snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 6126ddf2b9..875f6f33d3 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -309,11 +309,13 @@ bsock_send(argc, argv, sock)
if (n < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_fd_writable(fd);
goto retry;
}
rb_sys_fail("send(2)");
@@ -367,11 +369,14 @@ s_recv(sock, argc, argv, from)
if (RSTRING(str)->len < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_wait_fd(fd);
goto retry;
}
rb_sys_fail("recvfrom(2)");
@@ -422,7 +427,7 @@ mkipaddr(addr)
error = getnameinfo(addr, SA_LEN(addr), buf, sizeof(buf), NULL, 0,
NI_NUMERICHOST);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
return rb_str_new2(buf);
}
@@ -453,13 +458,13 @@ ipaddr(sockaddr)
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr1 = rb_str_new2(hbuf);
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr2 = rb_str_new2(hbuf);
port = INT2FIX(atoi(pbuf));
@@ -479,7 +484,7 @@ setipaddr(name, addr)
sin = (struct sockaddr_in *)addr;
if (name[0] == 0) {
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = INADDR_ANY;
@@ -490,11 +495,11 @@ setipaddr(name, addr)
sin->sin_addr.s_addr = INADDR_BROADCAST;
}
else {
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
error = getaddrinfo(name, NULL, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
/* just take the first one */
memcpy(addr, res->ai_addr, res->ai_addrlen);
@@ -502,17 +507,27 @@ setipaddr(name, addr)
}
}
+static void
+thread_write_select(fd)
+ int fd;
+{
+ fd_set fds;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ rb_thread_select(fd+1, 0, &fds, 0, 0);
+}
+
#if defined(HAVE_FCNTL)
static int
-thread_connect(fd, sockaddr, len, type)
+ruby_connect(fd, sockaddr, len, socks)
int fd;
struct sockaddr *sockaddr;
int len;
- int type;
+ int socks;
{
int status;
int mode;
- fd_set fds;
mode = fcntl(fd, F_GETFL, 0);
@@ -528,7 +543,7 @@ thread_connect(fd, sockaddr, len, type)
fcntl(fd, F_SETFL, mode|NONBLOCKING);
for (;;) {
#ifdef SOCKS
- if (type == INET_SOCKS) {
+ if (socks) {
status = Rconnect(fd, sockaddr, len);
}
else
@@ -538,22 +553,15 @@ thread_connect(fd, sockaddr, len, type)
}
if (status < 0) {
switch (errno) {
-#ifdef EAGAIN
case EAGAIN:
#ifdef EINPROGRESS
case EINPROGRESS:
#endif
- rb_thread_fd_writable(fd);
+ thread_write_select(fd);
continue;
-#endif
#ifdef EISCONN
case EISCONN:
-#endif
-#ifdef EALREADY
- case EALREADY:
-#endif
-#if defined(EISCONN) || defined(EALREADY)
status = 0;
errno = 0;
break;
@@ -565,6 +573,29 @@ thread_connect(fd, sockaddr, len, type)
return status;
}
}
+
+#else
+
+#ifdef SOCKS
+static int
+ruby_connect(fd, sockaddr, len, socks)
+ int fd;
+ struct sockaddr *sockaddr;
+ int len;
+ int socks;
+{
+ if (socks) {
+ return Rconnect(fd, sockaddr, len);
+ }
+ else {
+ return connect(fd, sockaddr, len);
+ }
+}
+#else
+
+#define ruby_connect(fd, sockaddr, len, socks) connect(fd, sockaddr, len)
+
+#endif /* SOCKS */
#endif
static VALUE
@@ -595,7 +626,7 @@ open_inet(class, h, serv, type)
strcpy(pbuf, STR2CSTR(serv));
portp = pbuf;
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if (type == INET_SERVER) {
@@ -603,7 +634,7 @@ open_inet(class, h, serv, type)
}
error = getaddrinfo(host, portp, &hints, &res0);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
fd = -1;
@@ -621,19 +652,8 @@ open_inet(class, h, serv, type)
syscall = "bind(2)";
}
else {
-#if defined(HAVE_FCNTL)
- status = thread_connect(fd, res->ai_addr, res->ai_addrlen, type);
-#else
-#ifdef SOCKS
- if (type == INET_SOCKS) {
- status = Rconnect(fd, res->ai_addr, res->ai_addrlen);
- }
- else
-#endif
- {
- status = connect(fd, res->ai_addr, res->ai_addrlen);
- }
-#endif
+ status = ruby_connect(fd, res->ai_addr, res->ai_addrlen,
+ (type == INET_SOCKS));
syscall = "connect(2)";
}
@@ -698,10 +718,10 @@ tcp_s_gethostbyname(obj, host)
VALUE ary, names;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -737,7 +757,7 @@ tcp_s_gethostbyname(obj, host)
if (h == NULL) {
#ifdef HAVE_HSTERROR
extern int h_errno;
- rb_raise(rb_eSocket, (char *)hsterror(h_errno));
+ rb_raise(rb_eSocket, "%s", (char *)hsterror(h_errno));
#else
rb_raise(rb_eSocket, "host not found");
#endif
@@ -756,7 +776,7 @@ tcp_s_gethostbyname(obj, host)
case AF_INET:
{
struct sockaddr_in sin;
- memset(&sin, 0, sizeof(sin));
+ MEMZERO(&sin, struct sockaddr_in, 1);
sin.sin_family = AF_INET;
SET_SIN_LEN(&sin, sizeof(sin));
memcpy((char *) &sin.sin_addr, *pch, h->h_length);
@@ -770,7 +790,7 @@ tcp_s_gethostbyname(obj, host)
case AF_INET6:
{
struct sockaddr_in6 sin6;
- memset(&sin6, 0, sizeof(sin6));
+ MEMZERO(&sin6, struct sockaddr_in6, 1);
sin6.sin6_family = AF_INET;
sin6.sin6_len = sizeof(sin6);
memcpy((char *) &sin6.sin6_addr, *pch, h->h_length);
@@ -824,11 +844,14 @@ s_accept(class, fd, sockaddr, len)
if (fd2 < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ rb_thread_wait_fd(fd);
goto retry;
}
rb_sys_fail(0);
@@ -875,7 +898,7 @@ open_unix(class, path, server)
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) rb_sys_fail("socket(2)");
- memset(&sockaddr, 0, sizeof(sockaddr));
+ MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX;
strncpy(sockaddr.sun_path, path->ptr, sizeof(sockaddr.sun_path)-1);
sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0';
@@ -884,7 +907,7 @@ open_unix(class, path, server)
status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
}
else {
- status = connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
+ status = ruby_connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr), 0);
}
if (status < 0) {
@@ -939,10 +962,10 @@ ip_s_getaddress(obj, host)
struct sockaddr addr;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -961,18 +984,12 @@ udp_s_open(argc, argv, class)
VALUE class;
{
VALUE arg;
+ int socktype = AF_INET;
if (rb_scan_args(argc, argv, "01", &arg) == 1) {
- if (rb_obj_is_kind_of(arg, rb_cInteger)) {
- return sock_new(class, socket(NUM2INT(arg), SOCK_DGRAM, 0));
- }
- else {
- rb_raise(rb_eSocket, "argument must be Integer");
- }
- }
- else {
- return sock_new(class, socket(AF_INET, SOCK_DGRAM, 0));
+ socktype = NUM2INT(arg);
}
+ return sock_new(class, socket(socktype, SOCK_DGRAM, 0));
}
static struct addrinfo *
@@ -990,15 +1007,15 @@ udp_addrsetup(fptr, host, port)
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
struct sockaddr_in sin;
- int i = NUM2INT(host);
- memset(&sin, 0, sizeof(sin));
+ long i = NUM2LONG(host);
+ MEMZERO(&sin, struct sockaddr_in, 1);
sin.sin_family = AF_INET;
SET_SIN_LEN(&sin, sizeof(sin));
sin.sin_addr.s_addr = htonl(i);
error = getnameinfo((struct sockaddr *)&sin, SIN_LEN(&sin),
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
hostp = hbuf;
}
@@ -1014,12 +1031,12 @@ udp_addrsetup(fptr, host, port)
portp = STR2CSTR(port);
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
error = getaddrinfo(hostp, portp, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
return res;
@@ -1030,23 +1047,28 @@ udp_connect(sock, host, port)
VALUE sock, host, port;
{
OpenFile *fptr;
+ int fd;
struct addrinfo *res0, *res;
GetOpenFile(sock, fptr);
+ fd = fileno(fptr->f);
res0 = udp_addrsetup(fptr, host, port);
for (res = res0; res; res = res->ai_next) {
retry:
- if (connect(fileno(fptr->f), res->ai_addr, res->ai_addrlen) >= 0) {
+ if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
freeaddrinfo(res0);
return INT2FIX(0);
}
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fd);
goto retry;
}
}
@@ -1111,11 +1133,14 @@ udp_send(argc, argv, sock)
}
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
+
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fileno(f));
goto retry;
}
}
@@ -1354,20 +1379,24 @@ sock_connect(sock, addr)
VALUE sock, addr;
{
OpenFile *fptr;
+ int fd;
Check_Type(addr, T_STRING);
rb_str_modify(addr);
GetOpenFile(sock, fptr);
+ fd = fileno(fptr->f);
retry:
- if (connect(fileno(fptr->f), (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len) < 0) {
+ if (ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0) < 0) {
switch (errno) {
case EINTR:
+ rb_thread_schedule();
+ goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
- rb_thread_schedule();
+ thread_write_select(fd);
goto retry;
}
rb_sys_fail("connect(2)");
@@ -1476,7 +1505,7 @@ mkhostent(h)
if (h == NULL) {
#ifdef HAVE_HSTRERROR
extern int h_errno;
- rb_raise(rb_eSocket, (char *)hstrerror(h_errno));
+ rb_raise(rb_eSocket, "%s", (char *)hstrerror(h_errno));
#else
rb_raise(rb_eSocket, "host not found");
#endif
@@ -1534,10 +1563,10 @@ sock_s_gethostbyname(obj, host)
struct hostent *h;
if (rb_obj_is_kind_of(host, rb_cInteger)) {
- int i = NUM2INT(host);
+ long i = NUM2LONG(host);
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&addr;
- memset(sin, 0, sizeof(*sin));
+ MEMZERO(sin, struct sockaddr_in, 1);
sin->sin_family = AF_INET;
SET_SIN_LEN(sin, sizeof(*sin));
sin->sin_addr.s_addr = htonl(i);
@@ -1642,7 +1671,7 @@ sock_s_getaddrinfo(argc, argv)
host = port = family = socktype = protocol = flags = Qnil;
rb_scan_args(argc, argv, "24", &host, &port, &family, &socktype, &protocol,
- &flags);
+ &flags);
if (NIL_P(host)) {
hptr = NULL;
}
@@ -1654,7 +1683,7 @@ sock_s_getaddrinfo(argc, argv)
if (NIL_P(port)) {
pptr = NULL;
}
- else if (rb_obj_is_kind_of(port, rb_cInteger)) {
+ else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
pptr = pbuf;
}
@@ -1664,25 +1693,25 @@ sock_s_getaddrinfo(argc, argv)
pptr = pbuf;
}
- memset(&hints, 0, sizeof(hints));
- if (!NIL_P(family) && rb_obj_is_kind_of(family, rb_cInteger)) {
- hints.ai_family = FIX2INT(family);
+ MEMZERO(&hints, struct addrinfo, 1);
+ if (!NIL_P(family)) {
+ hints.ai_family = NUM2INT(family);
}
else {
hints.ai_family = PF_UNSPEC;
}
- if (!NIL_P(socktype) && rb_obj_is_kind_of(socktype, rb_cInteger)) {
- hints.ai_socktype = socktype;
+ if (!NIL_P(socktype)) {
+ hints.ai_socktype = NUM2INT(socktype);
}
- if (!NIL_P(protocol) && rb_obj_is_kind_of(protocol, rb_cInteger)) {
- hints.ai_protocol = protocol;
+ if (!NIL_P(protocol)) {
+ hints.ai_protocol = NUM2INT(protocol);
}
- if (!NIL_P(flags) && rb_obj_is_kind_of(flags, rb_cInteger)) {
- hints.ai_flags = flags;
+ if (!NIL_P(flags)) {
+ hints.ai_flags = NUM2INT(flags);
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
ret = mkaddrinfo(res);
@@ -1743,8 +1772,8 @@ sock_s_getnameinfo(argc, argv)
strcpy(pbuf, "0");
pptr = NULL;
}
- else if (rb_obj_is_kind_of(port, rb_cInteger)) {
- snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
+ else if (!NIL_P(port)) {
+ snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port));
pptr = pbuf;
}
else {
@@ -1752,21 +1781,21 @@ sock_s_getnameinfo(argc, argv)
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
- memset(&hints, 0, sizeof(hints));
+ MEMZERO(&hints, struct addrinfo, 1);
if (strcmp(STR2CSTR(af), "AF_INET") == 0) {
hints.ai_family = PF_INET;
}
- #ifdef INET6
+#ifdef INET6
else if (strcmp(STR2CSTR(af), "AF_INET6") == 0) {
hints.ai_family = PF_INET6;
}
- #endif
+#endif
else {
hints.ai_family = PF_UNSPEC;
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
sap = res->ai_addr;
}
@@ -1775,15 +1804,15 @@ sock_s_getnameinfo(argc, argv)
}
fl = 0;
- if (!NIL_P(flags) && rb_obj_is_kind_of(flags, rb_cInteger)) {
- fl = FIX2INT(flags);
+ if (!NIL_P(flags)) {
+ fl = NUM2INT(flags);
}
-gotsap:
+ gotsap:
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) {
- rb_raise(rb_eSocket, gai_strerror(error));
+ rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
if (res)
freeaddrinfo(res);