Socket test

Here’s a test of the socket patch from Mono at r100:

[email protected]:/usr/src/svn/rubyforge.org/ironruby/trunk/tests/
ironruby$ cat socket-test.rb && echo ‘===’ && ruby socket-test.rb
require ‘socket’
streamSock = TCPSocket.new( “127.0.0.1”, 20000 )

IronRuby.Libraries:0:in `Require’: Could not load file or assembly
‘socket’ or one of its dependencies. The system cannot find the file
specified. (LoadError)

Is this a user error? Should I add something to the MONO_PATH?

Currently the Socket library is part of the IronRuby.Libraries.dll,
which is
all loaded up on start-up automatically. So you don’t need to do a
require
‘socket’ before the TCPSocket class is available.
If you want to write a program that will work on both IronRuby and other
flavours of Ruby then you can do the following at the top of your file.

begin
Socket
rescue
require ‘socket’
end

which is what appears in my RSpec socket tests at the moment

or perhaps more correctly

begin
require ‘socket’
rescue LoadError
end

Regards,
Pete

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