Christof Drescher writes:
Just wondering: A server can never GUARANTEE that a client as a recv() outstanding on the socket while no command is in progress, can it? Since no client can tell the server that it DOES a recv() by any means, it must assume that there is NO outstanding recv(), right?

No, it can ask TCP whether it's safe to send. The TCP send window's size is always known to the sending host.


On unix, you call select() and the return value will tell you whether it's safe to write to the fd. The return value does not tell you how many bytes you can safely write, though, but it generally will be thousands. So, to be careful you write code such as this:

    if the kernel says I can write
        if my write queue is empty
            add another EXISTS response to my write queue
        write the oldest part of the write queue

That'll generally add one EXISTS which the client will see "soon", but won't write anything if the TCP connection is already choked.

Arnt

Reply via email to