TCP output SSL support

This fixes and improves a few things in and adds SSL support to the TCP output.
would you mind moving the ssl setup block of code it its own method so that it doesn't "pollute" #register?