2 ;; very simple server started on port
4 (and (find-package "MAXIMA") (push :maxima
*features
*))
11 (defun user::setup
( port
&optional
(host "localhost"))
12 (let* ((sock (open-socket host port
)))
14 #+gcl
(setq si
::*sigpipe-action
* 'si
::bye
)
15 (setq *socket-connection
* sock
)
16 (setq *standard-input
* sock
)
17 (setq *standard-output
* sock
)
18 (setq *error-output
* sock
)
19 (setq *terminal-io
* sock
)
20 (format t
"pid=~a~%" (getpid))
22 (setq *debug-io
* sock
)
26 ;;; from CLOCC: <http://clocc.sourceforge.net>
27 (defun open-socket (host port
&optional bin
)
28 "Open a socket connection to HOST at PORT."
29 (declare (type (or integer string
) host
) (fixnum port
) (type boolean bin
))
30 (let ((host (etypecase host
32 (integer (hostent-name (resolve-host-ipaddr host
))))))
33 #+allegro
(socket:make-socket
:remote-host host
:remote-port port
34 :format
(if bin
:binary
:text
))
35 #+clisp
(socket-connect port host
:element-type
36 (if bin
'(unsigned-byte 8) 'character
))
38 #+cmu
(sys:make-fd-stream
(ext:connect-to-inet-socket host port
)
39 :input t
:output t
:element-type
40 (if bin
'(unsigned-byte 8) 'character
))
41 #+gcl
(si::socket port
:host host
)
42 #+lispworks
(comm:open-tcp-stream host port
:direction
:io
:element-type
43 (if bin
'unsigned-byte
'base-char
))
44 #-
(or allegro clisp cmu gcl lispworks
)
45 (error 'not-implemented
:proc
(list 'open-socket host port bin
))))
52 (setq $show_openplot nil
))