'Send "all" data on the connection. This calls send() repeatedly until
all data is sent. If an error occurs, it\'s impossible to tell how much
data has been sent.
:param buf: The string, buffer or memoryview to send
:param flags: (optional) Included for compatibility with the socket
API, the value is ignored
:return: The number of bytes written'

def sendall(self, buf, flags=0):

    buf = _text_to_bytes_and_warn('buf', buf)
    if isinstance(buf, _memoryview):
        buf = buf.tobytes()
    if isinstance(buf, _buffer):
        buf = str(buf)
    if (not isinstance(buf, bytes)):
        raise TypeError('buf    must    be    a    memoryview,    buffer    or    byte    string')
    left_to_send = len(buf)
    total_sent = 0
    data = _ffi.new('char[]', buf)
    while left_to_send:
        result = _lib.SSL_write(self._ssl, (data + total_sent), left_to_send)
        self._raise_ssl_error(self._ssl, result)
        total_sent += result
        left_to_send -= result
