[squeak-dev] Re: Webclient + localhost error

Frank Shearar frank.shearar at angband.za.org
Fri Oct 29 19:25:18 UTC 2010


On 2010/10/29 21:04, Sean P. DeNigris wrote:
>
> Duh, I kept thinking that and forgot...
>
> I tried a few different examples:
>    1. Starting with the one from the pickaxe book:
> 	server = TCPServer.new('localhost', 8091)
> 	while (session = server.accept)
> 		puts "Request: #{session.gets}"
> 		session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n"
> 		session.print "<html><body><h1>#{Time.now}</h1></body></html>\r\n"
> 		session.close
> 	end
>
>    2. server = TCPServer.open(2002)  # Socket to listen on port 2000
>      	loop {                         # Servers run forever
>      	    	client = server.accept       # Wait for a client to connect
>      	    	client.puts(Time.now.ctime)  # Send the time to the client
>      	    	client.puts "Closing the connection. Bye!"
>      		client.close                 # Disconnect from the client
>      	}
>
>    3. server = TCPServer.new('localhost', 8091)
> 	while (true)
> 	  begin
> 	      sock = server.accept_nonblock
> 	  rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
> 	      IO.select([server])
> 	      retry
> 	  end
> 	  sock.print "sdflkdsjfslkdj"
> 	  sock.close
> 	end
>
> All three work in Safari and fail in WebClient.

I'll put my neck on the block and boldly claim that if you change 
'localhost' to '127.0.0.1' WebClient will work.

frank



More information about the Squeak-dev mailing list