From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marko Rauhamaa Newsgroups: gmane.lisp.guile.user Subject: Nonblocking get-bytevector-n bug? Date: Sun, 06 Dec 2015 22:38:56 +0200 Message-ID: <87h9jvuxb3.fsf@elektro.pacujo.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1449434353 14519 80.91.229.3 (6 Dec 2015 20:39:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Dec 2015 20:39:13 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Dec 06 21:39:12 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 1a5g5O-00061Z-68 for guile-user@m.gmane.org; Sun, 06 Dec 2015 21:39:10 +0100 Original-Received: from localhost ([::1]:51020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5g5N-0005el-FK for guile-user@m.gmane.org; Sun, 06 Dec 2015 15:39:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5g5E-0005e0-N9 for guile-user@gnu.org; Sun, 06 Dec 2015 15:39:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5g5D-0004Hw-UJ for guile-user@gnu.org; Sun, 06 Dec 2015 15:39:00 -0500 Original-Received: from [2001:1bc8:1a0:5384:7a2b:cbff:fe9f:e508] (port=56394 helo=pacujo.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5g5D-0004Hm-Mz for guile-user@gnu.org; Sun, 06 Dec 2015 15:38:59 -0500 Original-Received: from elektro.pacujo.net (192.168.1.200) by elektro.pacujo.net; Sun, 6 Dec 2015 22:38:56 +0200 Original-Received: by elektro.pacujo.net (sSMTP sendmail emulation); Sun, 06 Dec 2015 22:38:56 +0200 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:1bc8:1a0:5384:7a2b:cbff:fe9f:e508 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:12216 Archived-At: Guile 2.0.11 provides: get-bytevector-n get-bytevector-n! get-bytevector-some Of these, only get-bytevector-some seems to behave as expected when the port is nonblocking: ======================================================================== (use-modules (rnrs io ports) (rnrs bytevectors)) (let ((port (fdes->inport 0))) (fcntl port F_SETFL (logior O_NONBLOCK (fcntl port F_GETFL))) (let loop () (catch 'system-error (lambda () (format #t "~s\n" (get-bytevector-some port))) (lambda syserr (format #t "err ~s\n" (system-error-errno syserr)))) (sleep 1) (loop))) ======================================================================== If you replace (get-bytevector-some port) with (get-bytevector-n port 8192) or (get-bytevector-n! port bv 0 8192), no partial data is returned. 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. Marko