tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: readv() on TCP socket returns 0
>> If you care about portability, I would recommend not counting on
>> this. For example, it wouldn't surprise me if some other OSes
>> returned zero for a nonblocking read with no data immediately
>> available. (I don't know of any specific examples.)
> That would be a bug -- how would you detect connection close in that
> case? Clearly such a read must return EWOULDBLOCK.
Or EAGAIN, or whatever the local analog is, yes.
But (a) even if we agree it's a bug, there are buggy systems out there,
sometimes even with very long-standing bugs; and (b), you would
preusmably detect connection close either by noticing that poll() or
local equivalent indicates nothing readable in one case but not the
other or by turning off nonblocking mode and trying another read.
(Yes, the latter has the issue that it blocks if there's nothing there;
some systems lack fairly obvious facilities in ways like this. Another
possibility is some system-specific call which allows detecting the
difference.)
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index