On Fri, 17 Mar 2000, Ove Kaaven wrote:
...
> > Hm, true. How about adding WS_FD_CLOSING flag that is set when we
> > receive POLLHUP?
>
> Another flag bit? Ugly, and not really necessary either. If you want to go
> forward with your solution, you could take advantage of WS_FD_READ |
> WS_FD_WRITE being present in the "state" field of operative sockets
> (including unconnected datagram sockets), and will be cleared on "socket
> abort". (They're not present in unconnected stream sockets, but those'll
> probably never call the reenabler anyway...)
>
> That means that you could probably just check for WS_FD_READ or
> WS_FD_WRITE in the state field, instead of WS_FD_CONNECTED.
>
> But I still think it's ugly... and MSG_PEEK would probably also miss any
> OOB data (not that OOB is well-handled at present anyway, but why make it
> worse).
>
The problem is that in order to post FD_CLOSE we need to know that there
is no more incoming data. I'm not quite sure how poll() reports this
condition. select() returns the socket as readable and only after read()
returns 0 bytes read you can be sure the socket is closed and buffers
are empty. Alternatively, there is an ioctl( fd, FIONREAD, ... ) call
that I used in the previous winsock implementation.
Alex