On Fri, Sep 18, 2009 at 23:50, Peter Stuge <[email protected]> wrote:
> Daniel Stenberg wrote:
>> Not at all. The socket being writable according to select() doesn't
>> imply that a write() or send() in blocking mode will return
>> immediately.
>
> I think that
>
> "A file descriptor  is considered ready if it is possible to perform
> the corresponding I/O operation (e.g., read(2)) without blocking."
>
> and
>
> "those in writefds will be watched to see if a write will not block"
>
> from select(2) not only implies but specifies exactly that.
[..]

select(2) doesn't know how much you want to write (or read), it only
detects that it's possible to read, or write, _some_ data without
blocking. I.e. if there's one byte available at a socket it will tell
you the socket is ready. When you try to read 100 bytes you'll block
in read(), if not set to non-blocking. The same can be the case with
writing: There's room to write a byte, so the socket is ready, there
may not be room to write all your bytes (e.g. window filled).

And, independently of blocking vs. nonblocking, read(2) or write(2)
can always return short when working on sockets (due to lots of
things, e.g. if some signal somewhere else in the application
interrupted the call).

-Tor
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to