From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Nonblocking get-bytevector-n bug? Date: Tue, 08 Dec 2015 10:39:31 -0500 Message-ID: <87k2opymoc.fsf@netris.org> References: <87h9jvuxb3.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1449589203 21587 80.91.229.3 (8 Dec 2015 15:40:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2015 15:40:03 +0000 (UTC) Cc: guile-user@gnu.org To: Marko Rauhamaa Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Dec 08 16:39:58 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a6KMr-0005Fe-UT for guile-user@m.gmane.org; Tue, 08 Dec 2015 16:39:54 +0100 Original-Received: from localhost ([::1]:60427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6KMr-00043a-BK for guile-user@m.gmane.org; Tue, 08 Dec 2015 10:39:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6KMi-00043L-Dz for guile-user@gnu.org; Tue, 08 Dec 2015 10:39:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6KMd-00072T-D0 for guile-user@gnu.org; Tue, 08 Dec 2015 10:39:44 -0500 Original-Received: from world.peace.net ([50.252.239.5]:52687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6KMd-00072M-9p for guile-user@gnu.org; Tue, 08 Dec 2015 10:39:39 -0500 Original-Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1a6KMW-0001Ru-Qx; Tue, 08 Dec 2015 10:39:32 -0500 In-Reply-To: <87h9jvuxb3.fsf@elektro.pacujo.net> (Marko Rauhamaa's message of "Sun, 06 Dec 2015 22:38:56 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 50.252.239.5 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12228 Archived-At: Marko Rauhamaa writes: > The problem with get-bytevector-some is that there is no limit to how > many bytes might be returned. In practice, I see that the amount is > capped at 4096 bytes, but the documentation does not guarantee any > limit. While I'm reluctant to guarantee any fixed limit, I can offer this: the returned bytevector will always be of a manageable size, assuming that you have not "unread" a huge amount of data, and that you haven't set a huge buffer size via 'setvbuf'. In the current implementation, the size is limited by the read buffer size of the port, or the size of the "putback" buffer. If 'get-bytevector-some' returns more data than you want, I would suggest using 'unget-bytevector' to "unread" the unwanted suffix. This procedure is quite efficient. 'unget-bytevector' was introduced in Guile 2.0.9. Would this work for you? Thanks, Mark