c - Given any epoll TCP socket event, if EPOLLRDHUP=0 and EPOLLIN=1; is a subsequent call to read()/recv() guaranteed to return a read size unequal to 0? -
from manual of epoll_ctl:
epollrdhup (since linux 2.6.17)
stream socket peer closed connection, or shut down writing half of connection. (this flag useful writing simple code detect peer shutdown when using edge triggered monitoring.)
from manual of recv:
if no messages available received , peer has performed orderly shutdown, recv() shall return 0.
it seems me both of above cover same scenarios, , long catch epollrdhup events first, should never receive read() or recv() of length 0 (and don't need bother checking such). guaranteed true?
if event epollrdhup=1
close connection right away without reading. if event epollrdhup=0
, epollin=1
go ahead , read, should prepared handle possibility of recv()
still returning 0, in case. perhaps fin
arrives after got epollin=1
before call recv()
.
Comments
Post a Comment