[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Premature eof-object ?


I have a problem in the following code.

I would like to retrieve the image db011214.gif

The code below stops when app. 16000 bytes of the 52000 bytes
have been downloaded.

I have tried two different ways of downloading.

In "copy-port", I use the same method as in "display-pure-port" in the net
In "copy-port2" I busy-wait until a char is ready (so I can be sure and
eof-object means eof-object
and not for example that the network is slow), but it gives the exact same

The copy I made on my own web server http://www.jensaxel.dk/db.gif can be
with no problems.

I use DrScheme v201a on windows 2000.

I tried to get the windows source from download.plt-scheme.org,
but it was not available. I wanted to look at the source for tcp-connect
in order to see whether an eof-object means eof or no-chars-available-now.

The code:

(require (lib "url.ss" "net"))
(require (lib "process.ss"))

(define (copy-port in out)
  (let loop ()
    (let ((c (read-char in)))
      (unless (eof-object? c)
        (write-char c out)

(define (copy-port2 in out)
  (let loop ()
    (let wait ((r (char-ready? in)))
      (if (not r)
          (wait (char-ready? in))
          (let ((c (read-char in)))
            (unless (eof-object? c)
              (write-char c out)

(define out (open-output-file "foo.gif" 'replace))

;(define in (get-pure-port (string->url http://www.jasoegaard.dk/db.gif)))

(define in (get-pure-port (string->url

;(copy-port in out)
(copy-port2 in out)

(close-output-port out)
(close-input-port in)

Jens Axel Søgaard

Jens Axel Søgaard