    # File lib/active_support/vendor/memcache-client-1.5.1/memcache.rb, line 787
        def socket
          @mutex.lock if @multithread
          return @sock if @sock and not @sock.closed?

          @sock = nil

          # If the host was dead, don't retry for a while.
          return if @retry and @retry > Time.now

          # Attempt to connect if not already connected.
          begin
            @sock = timeout CONNECT_TIMEOUT do
              TCPSocket.new @host, @port
            end
            if Socket.constants.include? 'TCP_NODELAY' then
              @sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
            end
            @retry  = nil
            @status = 'CONNECTED'
          rescue SocketError, SystemCallError, IOError, Timeout::Error => err
            mark_dead err.message
          end

          return @sock
        ensure
          @mutex.unlock if @multithread
        end