Function
comm
start-up-server &key function announce service process-name =>
A function name.
A keyword.
An integer or string.
A symbol or expression.
start-up-server function starts a TCP server. Usemp:process-kill to kill the server, andcomm:open-tcp-stream to send messages from another client to the server. make-instance and communicate with the client. The server does not accept more connections until function returns, so normally it creates another light-weight process to handle the connection. If no function is specified the built-in Lisp listener server is used. See the examples section below. SERVICES and is stored in theWindows directory., and on Windows NT it is the file %SystemRoot%\system32\drivers\etc\SERVICES
lispworks. (format nil "~S server" service)
(comm:start-up-server :service 10243)
READ. The client should send a string using CL syntax followed by a newline. This string is used to name a new light-weight process that runs a Lisp listener. When this has been created, the server waits for more connections. EOF if the other end closes the connection.
(defvar *talk-port* 10244) ; a free TCP port number
(defun make-stream-and-talk (handle)
(let ((stream (make-instance 'comm:socket-stream
:socket handle
:direction :io
:element-type
'base-char)))
(mp:process-run-function (format nil "talk ~D"
handle)
'()
'talk-on-stream stream)))
(defun talk-on-stream (stream)
(unwind-protect
(loop for line = (read-line stream nil nil)
while line
do
(format stream "You sent: '~A'~%" line)
(force-output stream))
(close stream)))
(comm:start-up-server :function 'make-stream-and-talk
:service *talk-port*)
open-tcp-streamsocket-stream