we call recv read for example 800 bytes into 1024 byte buffer
we send the response
now we dont need to call recv again as it will return EAGAIN, but we do (might cause race conditions with epoll events generated at the same time, although i dont think these race conditions could lead to serious problems)
scenario 2 (last request):
we get an EPOLLIN | EPOLLRDHUP event, but we have not registered EPOLLRDHUP so we dont know this
we call recv read for example 800 bytes into 1024 byte buffer
we send the response
now we dont need to call recv again as it will return 0, but we do
scenario 3 (last request, incomplete response):
we get an EPOLLIN | EPOLLRDHUP event, but we have not registered EPOLLRDHUP so we dont know this
we call recv read for example 800 bytes into 1024 byte buffer
we send the response but get EAGAIN
now we dont need to call recv again as it will return 0, but we do after we resume sending. problem here is that we need to store this information so we know that we do not have to recv
3 scenarios where we call recv more than needed:
scenario 1 (a request, but not the last one):
scenario 2 (last request):
scenario 3 (last request, incomplete response):