Add SSL error checking

Co-Authored-By: David Shrewsbury <shrewsbury.dave@gmail.com>

David Shrewsbury says:

"When SSL sockets are being used, calls to recv() and send() need to be
checked for two exceptions: ssl.SSL_ERROR_WANT_READ and
ssl.SSL_ERROR_WANT_WRITE, respectively.

These are commonly thrown by SSL and the proper thing to do is just
retry recv() or send() until that exception isn't thrown (see example below).

Secondly, when using SSL, the ssl code has an internal read buffer that
you need to drain. Use the ssl socket pending() call to check for that."

This also fixes a bug where the ServerConnection was not recognizing
the use of SSL.

Change-Id: Icf5a696a2685da19a9a027726fa92e6efaac9d2b
Merge "Add SSL error checking"