[plt-scheme] Re: Broken pipe communicating with Javascript XMLHttpRequest

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Wed Apr 13 08:46:03 EDT 2005

--- John Kozak <jk at xylema.org> wrote:

> I've had the same problem.  First suggestion: make sure
> that the
> server is sending the reply back with a content type of
> "text/xml".

Thanks for the suggestion.  I've given it a shot with no
luck.  I written a dummy server and redirected the
Javascript requests to it (you need to fiddle with
permissions in Moz, for anyone following along at home). 
The dummy server doesn't accept the first request, which is
to say tcp-accept doesn't return.  On the second and all
future requests it works correctly.  Could there be a race
condition in the tcp-accept code?  I'm now using Linux w/
299.102.  Console output and code below.


(define listener (tcp-listen 8100))

(printf "Up~n")

(let run-loop ()
  (let-values (((ip op) (tcp-accept listener)))
    (printf "Accepted connection~n")
    (let loop ((line (read-bytes-line ip 'any)))
      (if (eof-object? line)
          (printf "EOF~n")
            (printf "~a~n" line)
            (loop (read-bytes-line ip 'any)))))
    (display "bogus data" op)
    (close-output-port op)
    (close-input-port ip))

(define (close) (tcp-close listener) (printf "Closed~n"))


> (load "dummy-server.ss")
Accepted connection
GET /servlets/list.ss?add=new%20item HTTP/1.1
Host: localhost:8100
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.7.6) Gecko/20050317 Firefox/1.0.2
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache


Email: noelwelsh <at> yahoo <dot> com
AIM: noelhwelsh

Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!

Posted on the users mailing list.