[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
am I stupid? I crashed my Mac 10 times with 9 lines of code.
- To: comp-lang-lisp-mcl@services.cambridge.apple.com
- Subject: am I stupid? I crashed my Mac 10 times with 9 lines of code.
- From: philg@zurich.ai.mit.edu (Philip Greenspun)
- Date: 18 Aug 94 13:17:43
- Distribution: world
- Newsgroups: comp.lang.lisp.mcl
- Organization: M.I.T. Artificial Intelligence Lab.
- Reply-to: philg@mit.edu
Remember I said I wanted a function to go out to the network and grab
a URL? As the response to that post was underwhelming (Kalman, where
are you?), I decided to try my own skills. I get only about half the
data from the URL (maybe because the connection goes from :ESTABLISHED
to something else but there is still something in the input buffer?
Earlier I waited until the connection was actually in :CLOSED and got
lots of NILs but not more real characters.
What is worse, every time I interrupted this or did anything at all
out of the ordinary, my ENTIRE Macintosh would crash (this one doesn't
crash if you leave it alone).
My version of MacTCP.lisp is dated March 20, 1992 (is this the latest?).
My version of the system extension is 2.04 (the latest I think).
Thanks,
Philip
;-*- Mode: Lisp; Package: CCL -*-
(require 'mactcp)
(defun get-http-url (hostname filename)
(let* ((request (format nil "GET ~a HTTP/1.0" filename))
stream)
(unwind-protect
(progn (setq stream (open-tcp-stream hostname 80))
(format stream request)
(write-char #\CR stream)
(write-char #\LF stream)
(write-char #\CR stream)
(write-char #\LF stream)
(force-output stream)
(loop until (not (eq :established (tcp-state-name
(tcp-connection-state stream))))
collect (stream-tyi stream))
)
(stream-close stream))))
then type
(get-http-url "www-swiss.ai.mit.edu" "/")
(concatenate 'string *)
for comparison, from a UNIX box try
telnet www-swiss.ai.mit.edu 80
GET / HTTP/1.0 <crlf><crlf>
and see that you get twice as much back.
--
-- Philip Greenspun
-------------------------------------------------------------
MIT Department of Electrical Engineering and Computer Science
545 Technology Square, Rm 433, Cambridge, MA 02139, (617) 253-8574
Personal Web URL: http://www-swiss.ai.mit.edu/~philg/philg.html
summer address: PO Box 952, Los Alamos, NM 87544 (505) 665-0131