    # File lib/active_support/vendor/memcache-client-1.6.5/memcache.rb, line 796
        def socket
          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 ? TCPTimeoutSocket.new(@host, @port, @timeout) : TCPSocket.new(@host, @port)

            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
            logger.warn { "Unable to open socket: #{err.class.name}, #{err.message}" } if logger
            mark_dead err
          end

          return @sock
        end