Why 'send' doesn't mean 'receive'

Did you ever have this happen to you? You think you understand a piece of technology really well because it is so fundamental. But then someone comes and exposes how much you misunderstood something.

This happened to me today in a question regarding BSD sockets.

The debate was this - when a 'send()' call returns success, what does it *mean*? Does it mean

I'm willing to bet that a lot of you are confused now (or I hope so atleast for the sake of my ego). What did 'send()' actually succeed at?

The correct answer is the last one - that the message was successfully copied into some buffer into kernel space. In fact, one of the ways in which send() can fail is if the buffer doesn't have enough space to squeeze in your data.

You can see this specifically mentioned at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/send_2.asp

Why was I confused? Probably because my mental image of 'send()' has always been 'the network transmission call that blocks' and I associated blocking with the slow act of sending data over the network.

In case anyone is wondering, this debate didn't arise due to BSD sockets. We have an internal library that is supposed to 'mimic' BSD sockets semantics and I was sure I had found a bug when I found the 'send()' call succeeding before the other side had got the data.

You learn something new everyday. What's next? A bug in my hello world programs?


Comments:
remembers me,
nokia's message sent.

there's difference between,

message sent, and
message delivered
 
Post a Comment



<< Home

Archives

November 2004   January 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006   January 2007   February 2007   March 2007   April 2007   May 2007   June 2007   July 2007   August 2007   September 2007   October 2007   December 2007   January 2008   February 2008   March 2008   April 2008   May 2008