Webrick startup error

on:

$ sudo webrick_test.rb

where webrick_test.rb reads:

#!/usr/local/bin/ruby

require 'webrick'

PORT = 8809
DOCUMENT_ROOT = Dir.pwd

s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>
DOCUMENT_ROOT

trap('INT') { s.shutdown }

s.start

no matter what port i use i get this:

[2006-05-24 18:07:16] INFO WEBrick 1.3.1
[2006-05-24 18:07:16] INFO ruby 1.8.4 (2005-12-24) [i686-linux]
[2006-05-24 18:07:16] WARN TCPServer Error: Address already in use -
bind(2)
[2006-05-24 18:07:16] WARN TCPServer Error: Address already in use -
bind(2)
/usr/local/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Address
already in use - bind(2) (Errno::EADDRINUSE)
  from /usr/local/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
  from /usr/local/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
  from /usr/local/lib/ruby/1.8/webrick/server.rb:75:in `listen'
  from /usr/local/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
  from /usr/local/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
  from ./webrick_test.rb:8

running ruby 1.8.4 on Linux Ubuntu Breazy

all suggestions appreciated,
_c

···

--
Posted via http://www.ruby-forum.com/.

incidentally i have no such errors when i use TCPServer

require 'socket'

port = (ARGV[0] || 8808).to_i
server = TCPServer.new('localhost', port)
while session = server.accept
  req = session.gets
  puts "Request: #{req}"
  session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n"
  session.print "<h1>#{req}</h1>"
  session.close
end

···

--
Posted via http://www.ruby-forum.com/.

Use ":Port" instead of ":port".

HTH

Gotoken

···

2006/5/25, polypus <polypus@yahoo.com>:

s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>

s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>

Use ":Port" instead of ":port".

doh!

thx

···

--
Posted via http://www.ruby-forum.com/\.

polypus wrote:

s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>

Use ":Port" instead of ":port".

doh!

thx

Yeah, but it *should* work. That needs refactoring.

Regards,

Dan

No, WEBrick only uses :StudlyCaps.

···

On May 25, 2006, at 10:09 AM, Daniel Berger wrote:

polypus wrote:

s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>

Use ":Port" instead of ":port".

doh!
thx

Yeah, but it *should* work. That needs refactoring.

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com