would be better to rewrite to (IMHO):

``` ruby
@socket.close if @socket
@socket = nil
```