Don't understand connectedness for Metric Spaces

My book says that a metric space $E$ is connected if the only subsets of $E$ that are both open and closed are $E$ and $\varnothing$.

It goes on to say that if a space $E$ is not connected then it has a subset $A$ that is both open and closed and whose complement is also both open and closed.

Then it says that $E$ is the union of these two sets, both of which are open … .

So how did $A$ and its complement go from being open and closed to open? (I don't really know what it means to be both open and closed either; only closed, open or neither).

For example, in $\mathbb{R}$, the set $\mathbb{R}$ is open. However, $\mathbb{R}$ is also closed in $\mathbb{R}$, since its complement in $\mathbb{R}$, $\emptyset$, is open. Similarly, $\emptyset$ is both open and closed in $\mathbb{R}$, as it and its complement are both open.
It is fairly easy to see that in any space $X$, both $\emptyset$ and $X$ must be both open and closed, using the same sort of reasoning as with $\mathbb{R}$ above.