On Thursday, December 30, 2010 11:12:52 pm Mohnish J. wrote:
> Hi,
> 
> I am trying to build a chat application purely using Ruby. I have looked
> at the example on http://www.rubyinside.com/advent2006/10-gserver.html .
> The code in the example doesn't seem to be working for me. On running
> the ruby script on the terminal, and connecting to the url:
> http://localhost:1234 in my browser, I indefinitely encounter a
> "Transferring data from localhost..." message.

GServer is a TCP server. It's not a webserver. You can certainly build a 
webserver on top of it, but I don't know why you would, when there's five or 
ten good webservers for Ruby already, available as gems.

From your code, it sure doesn't look like you've written a webserver, so maybe 
open a terminal and type:

nc localhost 1234

...except that's probably going to just quit, since you don't actually ever 
write anything, as far as I can tell.

> May be I
> need to specify something in the command line while executing the script
> or I am supposed to start the chat(input output) through some other
> place(probably the browser).

Since it's a GServer example, I'm guessing you want something like netcat.

Also, it looks like the "serve" method is designed to be an entire TCP 
connection, so if you were intending this to be a persistent connection (as 
you'd have with a chat server), you'd need some sort of loop, as in the 
original code.