From owner-freebsd-hackers Wed Nov 6 12:47:20 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id MAA24208 for hackers-outgoing; Wed, 6 Nov 1996 12:47:20 -0800 (PST) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id MAA24194 for ; Wed, 6 Nov 1996 12:47:15 -0800 (PST) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id MAA12018; Wed, 6 Nov 1996 12:46:40 -0800 (PST) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma012014; Wed Nov 6 12:46:15 1996 Received: (from archie@localhost) by bubba.whistle.com (8.7.5/8.6.12) id MAA08387; Wed, 6 Nov 1996 12:46:15 -0800 (PST) From: Archie Cobbs Message-Id: <199611062046.MAA08387@bubba.whistle.com> Subject: Re: Limiting bandwidth on a socket? (SO_RCVBUF?) In-Reply-To: <199611061411.IAA08311@brasil.moneng.mei.com> from Joe Greco at "Nov 6, 96 08:11:58 am" To: jgreco@brasil.moneng.mei.com (Joe Greco) Date: Wed, 6 Nov 1996 12:46:15 -0800 (PST) Cc: hannibal@cyberstation.net, hackers@freebsd.org X-Mailer: ELM [version 2.4ME+ PL25 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > I'm trying to come up with some way to limit the amount of bandwidth on a > > socket, so I can have my mail and large files retrieve without slowing > > down a telnet session that much. > > > > [ ... ] > > > > Anyone know how to do this? > > int s, rval; > > s = socket(...); > > while ((rval = read(..., 1024)) > 0) { > sleep(1); > } > > if (rval < 0) { > perror(...); > } This also might be a good application for divert(4) sockets .. just stick in a daemon that throttles the I/O on whatever connections you want to throttle... basically, doing the same as above except your exiting applications don't have to be modified. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com