// Write writes the given data to the TLS connection. func (t *TLS) Write(buf []byte) (int, error) { var outlen C.size_t p := C.CString(string(buf)) defer C.free(unsafe.Pointer(p)) if C.tls_write(t.ctx, unsafe.Pointer(p), C.size_t(len(buf)), (*C.size_t)(unsafe.Pointer(&outlen))) != 0 { return -1, fmt.Errorf("write failed: %v", t.Error()) } return int(outlen), nil }
// Write writes the given data to the TLS connection. func (t *TLS) Write(buf []byte) (int, error) { p := C.CString(string(buf)) defer C.free(unsafe.Pointer(p)) ret := C.tls_write(t.ctx, unsafe.Pointer(p), C.size_t(len(buf))) switch { case ret == C.TLS_WANT_POLLIN: return -1, errWantPollIn case ret == C.TLS_WANT_POLLOUT: return -1, errWantPollOut case ret < 0: return -1, fmt.Errorf("write failed: %v", t.Error()) } return int(ret), nil }