When to use the POLLOUT event of the poll C function?

后端 未结 3 2040
醉话见心
醉话见心 2021-02-03 12:11

I wrote a small TCP servers with socket() + POLLIN poll() + recv() + send(), but I don\'t know when to use <

3条回答
  •  攒了一身酷
    2021-02-03 12:50

    From nginx source, I found that:

    If there is some data to send out, nginx tries to send it with a syscall (maybe writev). However, if nginx can not send total data at one time, it will set POLLOUT on pollfd, if using poll event, to wait for a writable event. When getting a writable event, nginx will send the left data.

    It is easy to reproduce this case when nginx tries to response large static file

提交回复
热议问题