Add TCP keepalive

This doesn't include realtime updates to the current connection
when the preferences are changed, although that would be possible.