# Socket test

**URL:** <https://www.ruby-forum.com/t/socket-test/137150>\
**Category:** IronRuby\
**Created:** [May 9, 2008, 1:20pm UTC](https://www.ruby-forum.com/t/socket-test/137150 "2008-05-09T13:20:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![C.JSAdams-Collier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@C.JSAdams-Collier](https://www.ruby-forum.com/u/C.JSAdams-Collier)\
**Post date:** [May 9, 2008, 1:20pm UTC](https://www.ruby-forum.com/t/socket-test/137150/1 "2008-05-09T13:20:24Z")

</div>

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

# cjcollier@karma:/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?

---

<div class="post-metadata">

**Author:** ![C.JSAdams-Collier](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@C.JSAdams-Collier](https://www.ruby-forum.com/u/C.JSAdams-Collier)\
**Post date:** [May 9, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/socket-test/137150/2 "2008-05-09T13:39:22Z")

</div>

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
