diff --git a/src/uvw/stream.h b/src/uvw/stream.h
index 88d6dc11..c83704c0 100644
--- a/src/uvw/stream.h
+++ b/src/uvw/stream.h
@@ -372,6 +372,30 @@ public:
return bw;
}
+ /**
+ * @brief Queues a write request if it can be completed immediately.
+ *
+ * Same as `tryWrite` for sending handles over a pipe.
+ * An ErrorEvent event will be emitted in case of errors.
+ *
+ * @param data The data to be written to the stream.
+ * @param len The lenght of the submitted data.
+ * @param send A valid handle suitable for the purpose.
+ * @return Number of bytes written.
+ */
+ template
+ int tryWrite(std::unique_ptr data, unsigned int len, StreamHandle &send) {
+ uv_buf_t bufs[] = { uv_buf_init(data.get(), len) };
+ auto bw = uv_try_write2(this->template get(), bufs, 1, send.raw());
+
+ if(bw < 0) {
+ this->publish(ErrorEvent{bw});
+ bw = 0;
+ }
+
+ return bw;
+ }
+
/**
* @brief Queues a write request if it can be completed immediately.
*
@@ -395,6 +419,30 @@ public:
return bw;
}
+ /**
+ * @brief Queues a write request if it can be completed immediately.
+ *
+ * Same as `tryWrite` for sending handles over a pipe.
+ * An ErrorEvent event will be emitted in case of errors.
+ *
+ * @param data The data to be written to the stream.
+ * @param len The lenght of the submitted data.
+ * @param send A valid handle suitable for the purpose.
+ * @return Number of bytes written.
+ */
+ template
+ int tryWrite(char *data, unsigned int len, StreamHandle &send) {
+ uv_buf_t bufs[] = { uv_buf_init(data, len) };
+ auto bw = uv_try_write2(this->template get(), bufs, 1, send.raw());
+
+ if(bw < 0) {
+ this->publish(ErrorEvent{bw});
+ bw = 0;
+ }
+
+ return bw;
+ }
+
/**
* @brief Checks if the stream is readable.
* @return True if the stream is readable, false otherwise.