[Ecls-list] Fwd: [Maxima] ECL 9.12.3 and xmaxima
Karsten Poeck
karsten.poeck at gmail.com
Mon Jan 11 20:32:37 UTC 2010
In article
<eb9c4b9a1001102033k6f54c63ajc776ed9c1a40201f at mail.gmail.com>,
Robert Dodier <robert.dodier at gmail.com>
wrote:
> Hi, the problem mentioned below is triggered by trying to run
> XMaxima, if I am not mistaken. Any advice about how to
> create a socket of the appropriate type?
>
> best
>
> Robert Dodier
>
> ---------- Forwarded message ----------
> From: Alexandr Shadchin
> <alexandr.shadchin at gmail.com>
> Date: Sat, 09 Jan 2010 22:00:37 +0500
> Subject: [Maxima] ECL 9.12.3 and xmaxima
> To: Maxima List <maxima at math.utexas.edu>
>
> Hi!
>
> Not work xmaxima with ECL 9.12.3
>
> maxima-5.20.1/src/server.lisp function open-socket
>
> In ECL 9.12.3 (si::open-client-stream host port) return binary stream,
> but for maxima need character stream.
>
> (si::stream-external-format-set socket :element-type 'character)
> not help, print:
> Cannot change external formatof binary stream #<io stream localhost>
>
> I ran out of ideas how to fix it :(
>
> Sorry, my English
I don't know the specifics of xmaxima but with the following I can
create a server and client that communicate text-messages via a socket
on localhost.
;;;1 ecl instance as a server
(require :sb-bsd-sockets)
(defvar socket)
(defvar socket-accepted)
(defvar server-stream)
(setq socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream
:protocol :tcp))
(sb-bsd-sockets:socket-bind socket #(0 0 0 0) 8000)
(sb-bsd-sockets:socket-listen socket 5)
;;; this is blocking
(setq socket-accepted (sb-bsd-sockets:socket-accept socket))
(setq server-stream (sb-bsd-sockets:socket-make-stream socket-accepted
:element-type :default
:input t :output t
:buffering :none))
(write-line "Test" server-stream)
(force-output server-stream)
;;;another instance as a client
(require :sb-bsd-sockets)
(defvar client-socket)
(defvar address)
(defvar client-stream)
(setq address (sb-bsd-sockets:host-ent-address
(sb-bsd-sockets:get-host-by-name "localhost")))
(setq client-socket (make-instance 'sb-bsd-sockets:inet-socket :type
:stream :protocol :tcp))
(sb-bsd-sockets:socket-connect client-socket address 8000)
(setq client-stream (sb-bsd-sockets:socket-make-stream client-socket
:element-type :default
:input t :output t
:buffering :none))
(read-line client-stream)
More information about the ecl-devel
mailing list