Function sendfile
Source pub fn sendfile(
out_fd: i32,
in_fd: i32,
offset: Option<&mut i64>,
count: usize,
) -> Result<usize>
Expand description
sendfile(2) 从文件 fd 直接发送到 socket fd,绕过用户态缓冲区。
适用于静态文件服务(HTTP 静态资源、缓存持久化等)。
out_fd - 输出 fd(必须是 socket 或类似可写 fd)
in_fd - 输入 fd(必须是支持 sendfile 的文件 fd,不能是 socket)
offset - 输入偏移指针,None 表示使用当前文件偏移
count - 最多发送的字节数
实际发送的字节数(0 表示 EOF)