Clarification on how the I/O on a socket wakes up selec()
I have been working on a select driven program which deals with around 2k sockets. While debugging a program hung I've been observed that if a RST comes on the socket, it wakes up select() with both read_set and write_set set for that socket. And if I don't close the socket after a recv() there and re-call the select() on that socket it is waking up immediately after sleeping 0 secs. And this time onwards I'm seeing only read_set set.
I even looked at the kernel TCP code but couldn't find the answer on this. Any help is highly appreciated.
Thanks a lot in advance,