Nonblocking socket recv problem while using it with epoll?

It's completely normal for the first recv() in that case to return EAGAIN epoll() never told you if it was readable yet or not Every single recv() should be prepared to handle EAGAIN if you are using non-blocking sockets. Spurious wakeups are possible, so whenever an API like select() poll() or epoll() tells you that a socket is readable, it's only saying "it might be readable - give it a try.

It's completely normal for the first recv() in that case to return EAGAIN. Epoll() never told you if it was readable yet or not. Every single recv() should be prepared to handle EAGAIN if you are using non-blocking sockets.

Spurious wakeups are possible, so whenever an API like select(), poll() or epoll() tells you that a socket is readable, it's only saying "it might be readable - give it a try".

Id=1&secret=1 HTTP/1.0\r\n\r\n) in buffer. In that case why recv returns EAGAIN and what I have to do to process it properly? – milo Sep 8 '10 at 4:46 @milo: No.

Epoll_wait() only told you that there was a new socket to accept() - it did not tell you that there was data to read from the new socket. If recv() returns EAGAIN you either 1) process what data you've got already or 2) go back to epoll_wait() and wait some more. – caf Sep 8 '10 at 4:57 if 1) I cannot process any data... so if 2) I will return to epoll_wait i'll lose my data.

Right? – milo Sep 8 '10 at 5:27 @milo: You won't lose any data, unless you specifically throw it away. Until the data has been handed to you by recv(), the OS will hold on to it.

– caf Sep 8 '10 at 6:13 thnx, i've solved my problem. – milo Sep 8 '10 at 10:09.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions