def _write_callback(connection_id, data_buffer, data_length_pointer):
try:<EOL><INDENT>self = _connection_refs.get(connection_id)<EOL>if not self:<EOL><INDENT>socket = _socket_refs.get(connection_id)<EOL><DEDENT>else:<EOL><INDENT>socket = self._socket<EOL><DEDENT>if not self and not socket:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>data_length = deref(data_length_pointer)<EOL>data = bytes_from_buffer(data_buffer, data_length)<EOL>if self and not self._done_handshake:<EOL><INDENT>self._client_hello += data<EOL><DEDENT>error = None<EOL>try:<EOL><INDENT>sent = socket.send(data)<EOL><DEDENT>except (socket_.error) as e:<EOL><INDENT>error = e.errno<EOL><DEDENT>if error is not None and error != errno.EAGAIN:<EOL><INDENT>if error == errno.ECONNRESET or error == errno.EPIPE:<EOL><INDENT>return SecurityConst.errSSLClosedNoNotify<EOL><DEDENT>return SecurityConst.errSSLClosedAbort<EOL><DEDENT>if sent != data_length:<EOL><INDENT>pointer_set(data_length_pointer, sent)<EOL>return SecurityConst.errSSLWouldBlock<EOL><DEDENT>return <NUM_LIT:0><EOL><DEDENT>except (KeyboardInterrupt) as e:<EOL><INDENT>self._exception = e<EOL>return SecurityConst.errSSLPeerUserCancelled<EOL><DEDENT>
Callback called by Secure Transport to actually write to the socket

:param connection_id:
    An integer identifing the connection

:param data_buffer:
    A char pointer FFI type containing the data to write

:param data_length_pointer:
    A size_t pointer FFI type of the amount of data to write. Will be
    overwritten with the amount of data actually written on return.

:return:
    An integer status code of the result - 0 for success