From owner-freebsd-questions@FreeBSD.ORG Thu Aug 24 09:21:19 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AEF0216A4DA for ; Thu, 24 Aug 2006 09:21:19 +0000 (UTC) (envelope-from igorr@speechpro.com) Received: from speechpro.ru (speech-tech-2.ip.PeterStar.net [81.3.190.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CDFB43D49 for ; Thu, 24 Aug 2006 09:21:18 +0000 (GMT) (envelope-from igorr@speechpro.com) Received: from [192.168.2.26] (helo=sysadm.stc) by s1.stc with esmtp (Exim 4.53 (FreeBSD)) id 1GGBOn-000CY9-E9 for freebsd-questions@freebsd.org; Thu, 24 Aug 2006 13:21:17 +0400 Received: from localhost.stc ([127.0.0.1] helo=sysadm.stc) by sysadm.stc with esmtp (Exim 4.62 (FreeBSD)) (envelope-from ) id 1GGBOs-000Cy5-Qj for freebsd-questions@freebsd.org; Thu, 24 Aug 2006 13:21:22 +0400 Received: (from igorr@localhost) by sysadm.stc (8.13.6/8.13.6/Submit) id k7O9LMgY049852 for freebsd-questions@freebsd.org; Thu, 24 Aug 2006 13:21:22 +0400 (MSD) (envelope-from igorr) Date: Thu, 24 Aug 2006 13:21:22 +0400 From: Igor Robul To: freebsd-questions@freebsd.org Message-ID: <20060824092122.GA49450@sysadm.stc> References: <7.0.1.0.2.20060821212315.09b9aeb0@lariat.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.12-2006-07-14 X-Archived: Yes Subject: Re: Increasing socket send buffer size X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2006 09:21:19 -0000 On Tue, Aug 22, 2006 at 11:20:16AM -0700, Chuck Swiger wrote: > On Aug 21, 2006, at 8:50 PM, Brett Glass wrote: > >I'm working with a system in which a program is failing because it > >sometimes tries to write more data to a stream socket than will > >fit. It reports that it can't write to the socket because it's out > >of buffer space, then dies ungracefully. > > > >What's the best solution to this problem? > > Have the code wait a few milliseconds to tens of milliseconds and > retry the write()? Or switch to non-blocking mode and pay attention > to the return value from write, and retry as needed if and when write > () doesn't actually send out all of the bytes your request wanted it Use select() on socket, and write when it is ready