def close_connection
      if defined?(@socket) && @socket.is_a?(OpenSSL::SSL::SSLSocket)
        @socket.close
        @socket = nil
      end

      if defined?(@tcpserver) && @tcpserver.is_a?(TCPSocket)
        @tcpserver.close
        @tcpserver = nil
      end

      return true if @tcpserver.nil? && @socket.nil?
    end
def close_connection
      if defined?(@socket) && @socket.is_a?(OpenSSL::SSL::SSLSocket)
        @socket.close
        @socket = nil
      end

      if defined?(@tcpserver) && @tcpserver.is_a?(TCPSocket)
        @tcpserver.close
        @tcpserver = nil
      end

      return true if @tcpserver.nil? && @socket.nil?
    end
Gracefully close the connection