why would a socket read() set errno to EWOULDBLOCK but still read?

Hwa-jin Bae hwajin at sgi.com
Sat Jun 29 05:56:55 AEST 1991


>>>>> On 28 Jun 91 04:31:48 GMT, 6sigma2 at polari.UUCP (Brian Matthews) said:

Brian> |   I am doing a read() on a connected TCP socket (BSD 4.3) marked as
Brian> |non-blocking. For some reason, the read returns the proper number of
Brian> |characters read (or sometimes 0), but sets errno to EWOULDBLOCK.

Brian> Errno is only valid if the read fails.  If the read succeeds, the
Brian> value of errno shouldn't be used.


i think the original poster is knowledgable enough to know that.
read() on a non-blocking socket can still return EWOULDBLOCK if
the amount of bytes read is less than the amount of bytes requested.
usually, programs that do non-blocking I/O would ignore this error
and try again, if necessary.



*hwajin


--
protocol engines, inc.



More information about the Comp.unix.programmer mailing list