[plt-scheme] problems with read-char, line or read

From: Jacopo Malnati (jacopo.malnati at email.it)
Date: Tue Apr 5 18:04:54 EDT 2005

Hi, I've created a small webserver in Scheme as homework for my University 
in Lugano.
I run it using MzScheme (but also DrScheme).

I works REALLY FINE under MacOs but it sends bugged images under windows.
I think this is due to the different implementation of read-line. I also 
tryed read-char ( I thougnth that the problem was with read line, sending 
line by line and replacing "\n" after each line.. but it is the same with 
It seems that the first bit of the sent image are sent as 0 0 0 0 instead 
being the "real" jpg "starting bits" (sorry for my english but I'm tired!). 
The problem is while reading because If i use something like :

(let ([fd (open-input-file page-path)])
      (let read-loop ()
        (let ([filetext (read-char fd)])
            [(not (eof-object? filetext)) (begin
                                            (display (char->integer 
                                            (display "\n")
                                            (write-char filetext socket-out)
                                            (read-loop))]... ... ...

the (display (char->integer filetext)) function will diplay me the ASCII 
code of the read char... and for the first 4 positions, it says 0 0 0 0 and 
tha'ts NOT true.. logically when I'm sending it to the client, it is not 
able to render the image :(

Any suggestion?

If someone is interested, the webserver code is of course available ;) Just 
ask (it implements just the GET method)

Jacopo Malnati
Computer Science Student in Lugano 

 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 Con la Pietra Naturale puoi grigliare carne, pesce e verdura direttamente in tavola!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2743&d=6-4

Posted on the users mailing list.