c - libev 网络服务器读取文件

标签 c file webserver reactor libev

在 C 中使用 libev 创建小型网络服务器时,在不阻塞 react 器的情况下提供文件服务(打开、就绪、写入套接字)的最佳策略是什么?

我有一些建议一次阅读几个区 block ,但我不确定这是正确的方法。

谢谢,

最佳答案

I have across some recommendations to read a few blocks at a time but I am not sure this would be the right approach.

是的,这是一个非常标准的方法。

如果您使用的是 Linux,您可能喜欢使用 sendfile() .这样您就不必维护一个缓冲区,它会以 block 的形式读取文件,然后通过套接字将其发送。

关于c - libev 网络服务器读取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14714260/

相关文章:

java - 通过 JNA 将 InputStream 作为文件指针传递给 C 代码

c - MinGw 交叉编译

c++ - 使用 C++ 读取配置文件

php - 使用PHP播放声音

html - Linux - 传输文件和创建文件的区别 - 权限

linux - Busybox httpd : error 501 on POST request and cgi not executing on yocto linux-3. 10.53

处理算术给出错误: called object not a function or function pointer的C程序

java - 无法将中文字符写入文件名

eclipse - 如何卸载服务器适配器?

c - 列出 C 中的目标目录