From: Scott Thompson Date: 2003-08-14T08:24:43+09:00 Subject: Re: Ruby listens IPv6 > I think it was probably not "could not connect" exactly, more like > "failed > to get any response from server", since your program does not send > back any > response down the TCP socket. Your web browser won't display anything > unless > the server follows the HTTP protocol. Nope... It was a "could not connect". I managed to get it to connect to the ruby program by running ipconfig -a on my computer and determining that my IPv6 address for the loopback connection is [::1]. By entering http:[::1]/ into my browser I was able to see the "stuff" that I was interested in. Now the browser sat waiting for a response until the connection timed out... but it was able to finally connect. I was also able to get the ruby program to use IPv4 by replacing the host name "localhost" in my ruby script with the IPv4 address "127.0.0.1". That would imply to me that when Ruby resolves the hostname "localhost" it probably gets back an IPv6 address and, therefore, chooses to create an IPv6 socket. > Your program works; Ruby will use an IPv6 socket if it's available, > but such > a socket is able to accept incoming IPv4 connections too. Hmmm... for some reason that does not appear to be the case (at least on my system). The IPv6 port is open and listening, but connecting to it from the browser without specifying an IPv6 address fails. I have a vague niggling at the base of my skull which tells me that there may be a "problem" in the fact that I have a machine with two network cards (a wireless card and a "hardline" ethernet card). I seem to recall a post at one point to the effect that IPv6 to IPv4 may get "confused" in this configuration because it's not sure on which interface it should translate IPv4 to IPv6... or something like that. That may be total nonsense so no flames please. > To make such a TCP server work properly you really want to start off a > new > thread for each incoming request, so that multiple requests can be > handled > in parallel. There's an example midway through > http://www.rubygarden.org/ruby?SingletonTutorial > of a fake POP3 server. > > But for a real-life webserver, you could just use Webrick - which is > bundled > with ruby-1.8.0 now anyway. Oh... well the goal was not to create a Web Server... rather to learn a bit more about sockets. Thanks for the pointers though! I'll look at them. Scott