Questions about select for sockets

Ken Brown kbrown@cornell.edu
Tue Apr 6 15:44:56 GMT 2021


On 4/6/2021 10:33 AM, Corinna Vinschen wrote:
> On Apr  6 16:20, Corinna Vinschen wrote:
>> On Apr  3 14:16, Ken Brown via Cygwin-developers wrote:
>>> 4. Why do we set
>>>
>>>    except_ready = saw_shutdown_write () || saw_shutdown_read () ?
>>>
>>> I can't find any documentation that says that a shutdown should be
>>> considered an exceptional condition.  On the other hand, POSIX does say,
>>> "Other circumstances under which a socket may be considered to have an
>>> exceptional condition pending are protocol-specific and
>>> implementation-defined."  So maybe there's some Cygwin-specific reason for
>>> doing this?
>>
>> Nope, this is old (and wrong) cruft.  Neither Steven's book nor the
>> Linux man pages, nor testing on Linux imply that ready for exception
>> is used to indicate anything other than out-of-band data.  This should
>> be fixed.
> 
> We may also have to change the saw_shutdown_read/saw_shutdown_write
> handling.  I checked this on Linux and what happens is:
> 
>    After shutdown (fd, SHUT_RD), the socket is ready for reading and writing

This seems surprising to me.  Is it really the shutdown that caused it to be 
ready for writing in your test, or was it ready for writing anyway (e.g., 
because the relevant buffer was empty)?

Ken

>    After shutdown (fd, SHUT_RDWR), the socket is ready for reading and writing
>    After shutdown (fd, SHUT_WR), the socket is ready for writing only.
> 
> 
> Corinna
> 


More information about the Cygwin-developers mailing list