From owner-freebsd-hackers Thu Nov 14 19:55:40 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA09432 for hackers-outgoing; Thu, 14 Nov 1996 19:55:40 -0800 (PST) Received: from brasil.moneng.mei.com (brasil.moneng.mei.com [151.186.109.160]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id TAA09423 for ; Thu, 14 Nov 1996 19:55:35 -0800 (PST) Received: (from jgreco@localhost) by brasil.moneng.mei.com (8.7.Beta.1/8.7.Beta.1) id VAA26930; Thu, 14 Nov 1996 21:53:10 -0600 From: Joe Greco Message-Id: <199611150353.VAA26930@brasil.moneng.mei.com> Subject: Re: Sockets question... To: jdp@polstra.com (John Polstra) Date: Thu, 14 Nov 1996 21:53:09 -0600 (CST) Cc: scrappy@ki.net, jgreco@brasil.moneng.mei.com, hackers@FreeBSD.org In-Reply-To: <199611150002.QAA10843@austin.polstra.com> from "John Polstra" at Nov 14, 96 04:02:52 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > > > 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