unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Nonblocking get-bytevector-n bug?
@ 2015-12-06 20:38 Marko Rauhamaa
  2015-12-07  9:50 ` Ludovic Courtès
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Marko Rauhamaa @ 2015-12-06 20:38 UTC (permalink / raw)
  To: guile-user


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



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-09  0:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-06 20:38 Nonblocking get-bytevector-n bug? Marko Rauhamaa
2015-12-07  9:50 ` Ludovic Courtès
2015-12-07 10:21   ` Taylan Ulrich Bayırlı/Kammer
2015-12-07 10:58     ` Taylan Ulrich Bayırlı/Kammer
2015-12-07 14:42       ` Ludovic Courtès
2015-12-08 10:53         ` tomas
2015-12-07 10:28   ` Marko Rauhamaa
2015-12-07 11:15     ` Marko Rauhamaa
2015-12-07 12:44 ` Amirouche Boubekki
2015-12-07 12:52   ` Marko Rauhamaa
2015-12-08 15:39 ` Mark H Weaver
2015-12-08 17:34   ` Marko Rauhamaa
2015-12-08 19:28     ` Chris Vine
2015-12-08 21:51       ` Marko Rauhamaa
2015-12-08 22:02         ` Marko Rauhamaa
2015-12-09  0:52           ` Chris Vine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).