This is Problem 3.19.3 of Dieudonné's Foundations of Modern Analysis (in my words). For $x$ a rational number, let $E_x=\{x\}\times\left[-1,0\right[$, and for $x$ an irrational number, let $E_x=\{x\}\times[0,1]$. Let $E=\bigcup_{x\in\mathbf{R}}E_x$ with the subspace topology. Show that $E$ is connected.
There is the following hint: "Use (3.19.1) and (3.19.6) to study the structure of a subset of $E$ which is both open and closed."
(3.19.1) is the fact that the connected subspaces of $\mathbf{R}$ are intervals and that intervals are connected. (3.19.6) is the fact that any open set of $\mathbf{R}$ is a countable disjoint union of open intervals.
My thoughts: Let $A$ be a clopen subset of $E$. It is fairly obvious that, for any $x\in\mathbf{R}$, $A$ contains either all elements or no element of $E_x$. So we define a subset $B$ of the real line by $B=\{x\in\mathbf{R}:E_x\subset A\}$. Now I thought that $B$ has to be clopen as well (in $\mathbf{R}$). But I can't prove it. I have no problems showing that any irrational point of $B$ is an interior point, and that any irrational point of $\overline{B}$ is in $B$, but nothing about rational points. I was pretty sure that this is the way to go, since the hint is exclusively about subsets of $\mathbf{R}$.
Any (further) hint or comment is much appreciated.