Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 1996 21:53:09 -0600 (CST)
From:      Joe Greco <jgreco@brasil.moneng.mei.com>
To:        jdp@polstra.com (John Polstra)
Cc:        scrappy@ki.net, jgreco@brasil.moneng.mei.com, hackers@FreeBSD.org
Subject:   Re: Sockets question...
Message-ID:  <199611150353.VAA26930@brasil.moneng.mei.com>
In-Reply-To: <199611150002.QAA10843@austin.polstra.com> from "John Polstra" at Nov 14, 96 04:02:52 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > > Are you checking the return value from write() to make sure it actually
> > > thinks that N bytes were _written_?
> > >
> > 	*sigh*
> 
> Well now, wait a minute.  As long as you haven't set the socket for
> non-blocking I/O, the write will always block until it's written the
> full N bytes that you asked for.  In other words, the write will always
> return either -1 or N.  Only if it's set up for non-blocking I/O can it
> return a short count.  Writes are different from reads in this respect.

Hi John,

I don't recall anybody specifying which was the case... maybe I forgot.

Besides, I believe that good coding practice suggests that such things
should be checked for unless you are REALLY concerned about performance
and can NOT afford the hit of an extra compare and branch...

My experience has been that code sometimes gets handed down, and
assumptions that were one time true rapidly become false.

I do not care to get into a style war about this, however...  too much
battling going on lately.  :-)  I'll just say that "that is how I would
prefer to do it if it were my code."

... JG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611150353.VAA26930>