On Fri, Apr 20, 2012 at 13:17, David Fooks <[email protected]> wrote:
> TCP has a whole ACK system built in so there must be a way to know that
> the receiving machine has my message. But none of the three options for this
> seem to change when the ACKs should no longer be received (when I pull the
> connections cable out):
>
> The three things I tried are:
>
> The return value of the socket.write(...) call which is always true even
> when the connection is lost.
> The callback of the socket.write(..., cb) call which is always called even
> the connection is lost.
> The event of the socket.on('drain') call which is always triggered even the
> connection is lost.
>
> How I'm I supposed to know when messages have not been received? The only

By tuning your kernel. The problem you're describing is not unique to Node.

What happens is that Node hands off the data to the kernel (that's
when the write callback fires), the kernel says "thank you very much"
and sends out the data at its leisure.

The TCP stack is designed to be resilient against transient network
errors. If there is a network problem, it will sit on the data until
a) the problem goes away or b) enough time passes that it becomes
unlikely that the problem will resolve itself. The timeout for b) is
configurable on most systems and it's usually on the order of many
minutes.

Now, it's only when b) happens that Node knows the data has not
actually been sent (because the kernel returns an error on the next
write). The one thing that Node could improve on here is to tell you
how many bytes remain in the send queue, that will let you reconstruct
how much data has actually been sent out.

> way I can see is to implement my own ACK system. But TCP has an ACK system
> implementing my own will double the network load! I should be told once my
> message has arrived at its recipient.
>
> Btw, I know about keepalives but they will only tell me that I have lost my
> connection but not what messages have been lost.
>
> Does anybody know how to do this?

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to