Skip to content

Commit b121e37

Browse files
committed
docs for new udp method
1 parent f67eaea commit b121e37

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/net/udp.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,22 @@ impl UdpSocket {
227227
}
228228

229229
/// Sends a message on the socket using a msghdr.
230+
///
231+
/// Returns a tuple of:
232+
///
233+
/// * Result containing bytes written on success
234+
/// * The original `io_slices` Vec<T>
235+
/// * The original `msg_contol` Option<U>
236+
///
237+
/// See the linux [kernel docs](https://www.kernel.org/doc/html/latest/networking/msg_zerocopy.html)
238+
/// for a discussion on when this might be appropriate. In particular:
239+
///
240+
/// > Copy avoidance is not a free lunch. As implemented, with page pinning,
241+
/// > it replaces per byte copy cost with page accounting and completion
242+
/// > notification overhead. As a result, zero copy is generally only effective
243+
/// > at writes over around 10 KB.
244+
///
245+
/// Note: Using fixed buffers [#54](https://github.com/tokio-rs/tokio-uring/pull/54), avoids the page-pinning overhead
230246
pub async fn sendmsg_zc<T: IoBuf, U: IoBuf>(
231247
&self,
232248
io_slices: Vec<T>,

0 commit comments

Comments
 (0)