Setup management of socket create/close.

Fixed up return-value handling.

Performed some refactoring...

(0) -3 +3 +10 +30 tip

mercurial