From: itojun@... Date: 1999-05-01T01:29:29+09:00 Subject: [ruby-dev:6698] Re: cvs repository ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <11530.925489631.1@coconut.itojun.org> Content-Transfer-Encoding: 7bit >| ただし、thread_connect()のどっかに問題があるらしく、添付の >| コードのc.getpeername()が成功しません(ENOTCONNが返る)。 >| デバッガで追ってると成功するので、「EAGAINだったらもう一度」の >| あたりでなにかいけないことが起きているように思います。 >添付のコードにc.getpeernameはないみたいなんですけど,もう一 >度再現するコードを見せて頂けませんか? まちがいましたすいません、こっちです。(http client側) itojun ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11530.925489631.2@coconut.itojun.org> Content-Transfer-Encoding: 7bit # simple webpage fetcher # The code demonstrates how a multi-protocol client should be written. # TCPsocket is using getaddrinfo() internally, so there should be no problem. require "socket" if ARGV.size != 1 STDERR.print "requires URL\n" exit end url = ARGV[0] if url !~ /^http:\/\/([^\/]+)(\/.*)$/ STDERR.print "only http with full hostname is supported\n" exit end # split URL into host, port and path hostport = $1 path = $2 if (hostport =~ /^(.*):([0-9]+)$/) host = $1 port = $2 else host = hostport port = 80 end if host =~ /^\[(.*)\]$/ host = $1 end #STDERR.print "url=<#{ARGV[0]}>\n" #STDERR.print "host=<#{host}>\n" #STDERR.print "port=<#{port}>\n" #STDERR.print "path=<#{path}>\n" STDERR.print "conntecting to #{host} port #{port}\n" c = TCPsocket.new(host, port) dest = Socket.getnameinfo(c.getpeername, Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV) STDERR.print "conntected to #{dest[0]} port #{dest[1]}\n" c.print "GET #{path} HTTP/1.0\n" c.print "Host: #{host}\n" c.print "\n" while c.gets print end ------- =_aaaaaaaaaa0--