Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

socket-connect problem

0 views
Skip to first unread message

Pedro Gonzalez Arellano

unread,
Oct 28, 1999, 3:00:00 AM10/28/99
to
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
pe...@cornella.lamalla.net


Clemens Heitzinger

unread,
Oct 28, 1999, 3:00:00 AM10/28/99
to
Pedro Gonzalez Arellano <p...@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

0 new messages