简体   繁体   中英

Sendfile without file descriptor

I have a memory region which contains data that I would like to send over ethernet to the other client. To increase the throughput, currently I am fiddling with sendfile API instead of the classic send/write API. But as far as I understand, the sendfile API requires a file descriptor for input, but what I have is only raw memory data. So what should I do in order to use the sendfile API?

The primary benefit of sendfile() is that it allows you to avoid the overhead of having to first read() data from a file descriptor into memory before you can send() it. If the data you want to send is already in memory, sendfile() is not needed. Using weird workarounds to move the data into a file (like mmap() ing it) will only reduce performance.

如果您运行的是Linux,则可以查看拼接

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM