Fix exception handling inside Socket#read

Also remove the useless shebang


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668973 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/lib/thrift/transport/socket.rb b/lib/rb/lib/thrift/transport/socket.rb
index 317d62b..88fed90 100644
--- a/lib/rb/lib/thrift/transport/socket.rb
+++ b/lib/rb/lib/thrift/transport/socket.rb
@@ -1,5 +1,3 @@
-#!/usr/bin/env ruby
-#
 # Copyright (c) 2006- Facebook
 # Distributed under the Thrift Software License
 #
@@ -46,13 +44,13 @@
     def read(sz)
       begin
         data = @handle.recv(sz)
-        if (data.length == 0)
-          raise TransportException.new("Socket: Could not read #{sz} bytes from #{@host}:#{@port}")
-        end
-        return data
       rescue StandardError
         raise TransportException.new(TransportException::NOT_OPEN)
       end
+      if (data.length == 0)
+        raise TransportException.new(TransportException::UNKNOWN, "Socket: Could not read #{sz} bytes from #{@host}:#{@port}")
+      end
+      return data
     end
 
     def close