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:increate_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:inlisten’
from /usr/local/lib/ruby/1.8/webrick/server.rb:63:in initialize' from /usr/local/lib/ruby/1.8/webrick/httpserver.rb:24:ininitialize’
from ./webrick_test.rb:8

running ruby 1.8.4 on Linux Ubuntu Breazy

all suggestions appreciated,
_c

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 “

#{req}


session.close
end

2006/5/25, polypus [email protected]:

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

Use “:Port” instead of “:port”.

HTH

Gotoken

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

Use “:Port” instead of “:port”.

doh!

thx

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

On May 25, 2006, at 10:09 AM, Daniel B. 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.

No, WEBrick only uses :StudlyCaps.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com