chazmeyers.com/blog


6 < 4.8?

Posted in ruby, General Programming Topics by chazmeyers on the February 28th, 2007

Like any good developer, I write code on a development server and then push the code to the production server. (Yay, SVN.) While testing out something, I noticed an odd inconsistency between the two.

Consider the following:

Code (ruby)
  1. sock = TCPSocket.new( ip, port )

Fairly simple. When I run it on my test server, I got this result:

Code (ruby)
  1. Errno::EINVAL: Invalid argument - connect(2)

When I see something like that, I presume that I made a blunder. Perhaps ip was an odd string, or port was a negative number. Who knows? I double checked myself. The ip and port were both valid.

Then I tried it out on our production server, just for the heck of it. I got this back:

Code (ruby)
  1. Errno::ECONNREFUSED: Connection refused - connect(2)

Turned out the server I was connecting to wasn’t up. A few minutes later, the server is back up and I am able to create sockets from both machines. What?

One possibility that crossed my mind was perhaps I was working with two different versions of Ruby. Check out the results from ruby -v:
dev: ruby 1.8.4 (2005-12-24) [i386-freebsd6]
production: ruby 1.8.4 (2005-12-24) [i386-freebsd4.8]

The only difference is the version of freebsd. I can only guess that freebsd 6’s standard library gives less specific error messages than freebsd 4.8. Either that, or our host upgraded the standard library without bumping the freebsd version number.

How peculiar.

Leaky Abstractions.

Posted in RubyOnRails, General Programming Topics by chazmeyers on the February 6th, 2007