Forum: Ruby webrick startup error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
polypus (Guest)
on 2006-05-25 05:14
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
polypus (Guest)
on 2006-05-25 07:45
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
GOTO Kentaro (Guest)
on 2006-05-25 09:08
(Received via mailing list)
2006/5/25, polypus <removed_email_address@domain.invalid>:

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

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

HTH

Gotoken
polypus (Guest)
on 2006-05-25 20:32
>> s = WEBrick::HTTPServer.new :port => PORT, :DocumentRoot =>
>
> Use ":Port" instead of ":port".
>

doh!

thx
Daniel B. (Guest)
on 2006-05-25 21:10
(Received via mailing list)
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
Eric H. (Guest)
on 2006-05-25 23:44
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
This topic is locked and can not be replied to.