MEDIUM: connection: add an error code in connections

This will be needed to improve error reporting, especially for SSL.
5 files changed