[In this answer I assume we are defining the empty set to be connected, or else requiring only that nonempty subsets be connected.]
Let $X$ be a topological space. Define a relation $\leq$ on $X$ by $x\leq y$ iff $x\in\overline{\{y\}}$ (this is the specialization preorder, or maybe its opposite depending on your conventions). It is easy to see that $\leq$ is transitive. Then the following are equivalent:
- A subspace of $X$ is compact iff it is connected
- Every subspace of $X$ is both compact and connected
- The relation $\leq$ is a pre-well ordering: that is, it is total and every nonempty subset of $X$ has a least element.
To prove this we will prove $(2)\Rightarrow (1)\Rightarrow (3)\Rightarrow (2)$. The implication $(2)\Rightarrow(1)$ is trivial.
Let us now suppose $(1)$ holds and prove that $(3)$ holds (we will also prove that $(2)$ holds along the way).
To prove totality of $\leq$, note that for any $x,y\in X$, $\{x,y\}$ is compact and hence connected. If $x\not\leq y$, then $\{y\}$ is closed as a subset of $\{x,y\}$, so $\{x\}$ cannot be closed by connectedness. This means that $y\in\overline{\{x\}}$, so $y\leq x$. Thus either $x\leq y$ or $y\leq x$.
It follows also that actually every subset of $X$ is connected. Indeed, if $A\subseteq X$ and $x,y\in A$, then since $\{x,y\}$ is connected a clopen subset of $A$ contains $x$ iff it contains $y$. It follows that a clopen subset of $A$ either contains no elements of $A$ or contains all elements of $A$, so $A$ is connected.
Thus every subset of $X$ is also compact. We now use this to prove that any nonempty subset $A\subseteq X$ has a least element. First, note that for any $x\in X$, the set $U(x)=\{y\in X:y\not\leq x\}$ is open in $X$. Indeed, if $y\in U(x)$, then since $y\not\leq x$ there exists some open set $U$ such that $y\in U$ but $x\not\in U$. For any $z\in U$, then, $x\not\leq z$ since $U$ is a neighborhood of $z$ not containing $x$. Thus $U\subseteq U(x)$.
Note also that if $y\leq x$, then $U(x)\subseteq U(y)$.
Now suppose there exists a nonempty subset $A\subseteq X$ which has no least element. For each $a\in A$, there exists some $b\in A$ such that $a\not\leq b$, so that $a\in U(b)$. So $A$ is covered by the open sets $U(b)$. Since $A$ is compact, there are finitely many $b_1,\dots,b_n\in A$ such that the sets $U(b_i)$ cover $A$. Taking a least element among the finitely many $b_i$ (which is possible since $\leq$ is total), we see there is a single element $b\in A$ such that $U(b)$ covers $A$. But this is impossible, since $b\in A$ and $b\not\in U(b)$.
Thus every nonempty subset of $X$ has a least element, so $\leq$ is a pre-well ordering of $X$. This concludes the proof that $(1)\Rightarrow (3)$.
Now suppose $(3)$ holds; we will prove $(2)$. The argument with two-point subspaces above can easily be reversed to show that if $\leq$ is total, then every two-point subspace of $X$ is connected, and that this implies in fact every subspace of $X$ is connected. So it just remains to be shown that every subspace of $X$ is compact.
To prove this, let $A\subseteq X$ be any nonempty subspace. By assumption, there is a least element $a\in A$. For any $b\in A$, then, $a\in\overline{\{b\}}$, which means any open set containing $a$ contains $b$. So the only open subset of $A$ containing $a$ is the entire space $A$. It follows that any open cover of $A$ must have $A$ itself as one of the open sets, so there is trivially a finite subcover (namely $\{A\}$). Thus every subspace of $X$ is compact.