From: Pedro Gonzalez Arellano
Subject: socket-connect problem
Date: 
Message-ID: <381802D1.17E4F84D@iiia.csic.es>
Hi,

Could somebody tell me how to open a socket stream with MacLisp?

I tried (socket-connect port-number host-name), but MacLisp says that
function
doesn't even exist.

Any other information about sockets in MacLisp could be useful for me.

   Thanks in advance.
   Pedro
   ·····@cornella.lamalla.net
From: Clemens Heitzinger
Subject: Re: socket-connect problem
Date: 
Message-ID: <1e0dy7v.hhr5n71k9qy9pN%cheitzin@ag.or.at>
Pedro Gonzalez Arellano <···@iiia.csic.es> wrote:

> Hi,
> 
> Could somebody tell me how to open a socket stream with MacLisp?
> 
> I tried (socket-connect port-number host-name), but MacLisp says that
> function
> doesn't even exist.
> 
> Any other information about sockets in MacLisp could be useful for me.

I don't know about MacLisp, but I assume you mean Macintosh Common Lisp.
The following gets an URL as a list of strings.


(require :opentransport)
(import 'ccl::open-tcp-stream)

(defun get-url-lines (server page &key (port 80) (start 0) (end nil))
  (let ((stream (open-tcp-stream server port)))
    (unwind-protect
      (progn
        (format stream "GET ~A HTTP/1.0~C~C~C~C" page #\newline
#\linefeed #\newline #\linefeed)
        (force-output stream)
        (prog1
          (loop for line = (read-line stream nil nil)
                for n = 0 then (1+ n)
                while (and line
                           (not (zerop (length line)))
                           (or (null end) (<= n end)))
                when (<= start n)
                collect line)
          (close stream)))
      (close stream))))

-- 
Clemens Heitzinger
http://ag.or.at:8000/~clemens