TCPServer issue

Hi
Someone knows why this source

#! /usr/bin/env ruby

require ‘socket’

srv = TCPServer.new ‘localhost’, 20000
loop do
Thread.start (srv.accept) do |s|
s.write time.now
s.close
end
end

causes this?:

code/ruby/stuff/socket.rb:5:in <top (required)>': uninitialized constant TCPServer (NameError) from ./socket.rb:3:inrequire’
from ./socket.rb:3:in `’

Also:
ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]

It seems to happen only to me =\

Hi –

On Sat, 1 May 2010, tilde wrote:

   s.write time.now

from ./socket.rb:3:in `’

Also:
ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]

It seems to happen only to me =\

It happens to me too, when I name my file socket.rb and use Ruby
1.9.1. I’m not sure why, since “.” (current directory) is at the very
end of the load path, but it appears to be loading your socket.rb
instead of the Ruby one.

David


David A. Black, Senior Developer, Cyrus Innovation Inc.

THE Ruby training with Black/Brown/McAnally
COMPLEAT Coming to Chicago area, June 18-19, 2010!
RUBYIST http://www.compleatrubyist.com

It happens to me too, when I name my file socket.rb and use Ruby
1.9.1. I’m not sure why, since “.” (current directory) is at the very
end of the load path, but it appears to be loading your socket.rb
instead of the Ruby one.

I think 1.9 started preferring .rb files over .so files, where possible.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/27522

-rp

On 30/04/2010 20:47, Roger P. wrote:

-rp
I haven’t think at this behavior of the interpreter, many thx ^^

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs