  We study the problem of existence of a periodic point in the boundary of an
invariant domain for a surface homeomorphism. In the area-preserving setting, a
complete classification is given in terms of rationality of Carath\'eordory's
prime ends rotation number, similar to Poincar\'e's theory for circle
homeomorphisms. In particular, we prove the converse of a classic result of
Cartwright and Littlewood. This has a number of consequences for generic area
preserving surface diffeomorphisms. For instance, we extend previous results of
J. Mather on the boundary of invariant open sets for $C^r$-generic area
preserving diffeomorphisms. Most results are proved in a general context, for
homeomorphisms of arbitrary surfaces with a weak nonwandering-type hypothesis.
This allows us to prove a conjecture of R. Walker about co-basin boundaries,
and it also has applications in holomorphic dynamics.
