the problem could be that your box is behind a restrictive firewall. you can install rails by hand. without using the gem paket manager.
try this link: http://ashishkulkarni.blogspot.com/2006/07/installing-ruby-and-rails-framework.html
it descripes how to install rails manually. is targeted to windows but
the gems should be the same.
google a bit around. there are a lot of results searching for "ERROR: While executing gem ... (SocketError)" e.g.