Brad Cox writes:
> I just joined this list. Sorry if this is a faq.
>
> On running the HelloWorld example on linux 7.0 + apache latest, I get
> this error. Same results with eruby.
>
> Any suggestions?
It is a FAQ. I asked it, too. Here's the answer I received from gotoyuzo:
> Sorry. Listening socket is not required for this test.
> Please try the following patch.
>
> --- TestWEBrickHTTPServer.rb~ Tue Feb 5 20:33:11 2002
> +++ TestWEBrickHTTPServer.rb Tue Feb 5 06:44:18 2002
> @@ -8,14 +8,8 @@
> include WEBrick
>
> def setup
> - (2000..3000).each{|port|
> - begin
> - logger = Log.new(nil, Log::FATAL)
> - @svr = HTTPServer.new(:Logger=>logger, :Port=>port)
> - break
> - rescue Errno::EACCES, Errno::EADDRINUSE
> - end
> - }
> + logger = Log.new(nil, Log::FATAL)
> + @svr = HTTPServer.new(:Logger=>logger, :ListenImmediately => false)
> end
>
> Socket::getaddrinfo may cause problem on some Linux box.
> See also http://www.ruby-talk.com/28598.
>
> --
> gotoyuzo
I also needed to set the :BindAddress address to '0.0.0.0' when starting
the server. Here's my httpd.rb:
require 'webrick'
require 'getopts'
DEFAULT_DOCROOT_DIR = File.join(File.dirname($0), 'src')
getopts nil, 'r:'
s=WEBrick::HTTPServer.new(
:BindAddress => '0.0.0.0',
:Port => 2000,
:Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG),
:DocumentRoot => $OPT_R || DEFAULT_DOCROOT_DIR
)
trap("INT"){ s.shutdown }
s.start
Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"Any sufficiently complicated C or Fortran program contains an ad hoc
informally-specified bug-ridden slow implementation of half of Common Lisp."
-- Greenspun's Tenth Rule of Programming