I have 2 'Seleccionar' calls one after other on same fd. both have diff fd_set, but both have only one fd int it and the same fd.(trying to read from the same socket)
the problem is second Select times out. I am trying to recreate the issue but cant, in my testing the second select goes through almost instantaneously, even with timeout=0.
I am confused. Does the Socket have data in Kernel Space due to which the second select goes through immediately.
preguntado el 08 de noviembre de 11 a las 14:11
Yes, the socket does have incoming data buffered in kernel space - that's what you'll get when you call
read(), after the first
select() returns to indicate that there is something available to read. If you haven't read it all yet, then of course another
select() Regresará inmediatamente.
Si tener llamado
read(), then it probably indicates that there's more data available than you've read, and you should carry on reading until you've got it all. There's only a problem here if either the call to
read() fails or blocks after
select has indicated that it's readable, or if you have reason to believe that there should be no data following what you've already read.