> > The block `ensure' is always executed, even if TCPSocket::open failed. > In this case `server' will have the value `nil' and this give the error. > > Just write > > server.close if server I did and: trying: 0 ../socket.rb:5: uninitialized constant TCPSocket (NameError) from ./socket.rb:2:in `each' from ./socket.rb:2 from socket.rb:1:in `require' from socket.rb:1