I’m learning to write non-blocking server and client applications using epoll, poll, etc. and came across this event flag:
POLLOUT:
Writing now will not block.
I understand the concept of blocking reads. But what are blocking writes?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In any I/O operation the potential to need a trip to the hard disk (or other slow I/O device) and back exists. A “blocking” call is simply one that waits while the round-trip I/O is being done — in the mean time, your . So, just like you can wait for reading to be done, so can you wait for writing.
This isn’t usually so useful for conventional applications — you want to tell the OS to write your data and then it’s not your problem anymore. It becomes your problem when you’re trying to guarantee data integrity stored on the I/O device (e.g. hard disk) such as in a relational database system. (Note that blocking isn’t the only method by which you can guarantee your writes have been done, however. Also note with the growing complexity of computers, there’s multiple layers of caching which may or may not interfere with actual blocking.)