Changed client interface to be more flexible.

The client should have access to the socket and decide himself when to
close it. For example, for ssl connections a different finalizer is
needed.