When to use the POLLOUT event for polling function C?

I wrote a small TCP servers socket()+ POLLIN poll() + recv()+ send(), but I do not know when to use POLLOUT poll or select writefdsto poll on record events.

Can someone give me an example of the real use of POLLOUT ?

+5
source share
2 answers

A common pattern is to use non-blocking file descriptors with the poll()following:

  • In preparation for poll(),
    • Always install POLLIN, because you are always interested in reading what the other end of the socket sends.
      • , , , , .
    • POLLOUT, .
  • poll(), , ,
    • -
  • poll(), , ,
    • .
      • , POLLOUT
      • ( ), . POLLOUT .
  • ( , , - ), :
    • . , . , , , POLLOUT , .
    • POLLOUT . ( , , , , .)
+15

nginx , :

- , nginx syscall (, writev). , nginx , POLLOUT pollfd, , , . nginx .

, nginx

0

All Articles