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

Premature eof-object ?



Hello

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
collection.
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
result.

The copy I made on my own web server http://www.jensaxel.dk/db.gif can be
downloaded
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)
        (loop)))))

(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)
              (loop)))))))


(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
"http://a1736.g.akamai.net/7/1736/1392/1dcf6501c8f9fe/images.ucomics.com/com
ics/db/2001/db011214.gif")))

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

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

Yours,
--
Jens Axel Søgaard
http://www.jensaxel.dk


--
Jens Axel Søgaard
<http://www.jensaxel.dk>