This is an attempt to add GCL-based socket support to SPAD
and to use it to implement a very simple web server.

First we create a Lisp interface for the GCL socket server-mode.
Unfortunately there is no common socket interface for Lisp.

GCL Sockets

The documentation for GCL sockets is available here:

$ info gcl-si.info

in the gcl/info directory of the GCL source distribution.
Look under the heading 'GCL specific':

Function: SOCKET (port &key host server async myaddr myport daemon)

Establishes a socket connection to the specified PORT under a
variety of circumstances.

If HOST is specified, then it is a string designating the IP
address of the server to which we are the client. ASYNC specifies
that the connection should be made asynchronously, and the call
return immediately. MYADDR and MYPORT can specify the IP address
and port respectively of a client connection, for example when the
running machine has several network interfaces.

If SERVER is specified, then it is a function which will handle
incoming connections to this PORT. DAEMON specifies that the
running process should be forked to handle incoming connections in
the background. If DAEMON is set to the keyword PERSISTENT, then
the backgrounded process will survive when the parent process
exits, and the SOCKET call returns NIL. Any other non-NIL setting
of DAEMON causes the socket call to return the process id of the
backgrounded process. DAEMON currently only works on BSD and
Linux based systems.

If DAEMON is not set or nil, or if the socket is not a SERVER
socket, then the SOCKET call returns a two way stream. In this
case, the running process is responsible for all I/O operations on
the stream. Specifically, if a SERVER socket is created as a
non-DAEMON, then the running process must LISTEN for connections,
ACCEPT them when present, and call the SERVER function on the
stream returned by ACCEPT.

Sockets in SPAD

Our objective is to be able to write a more sophisticated
web server in SPAD. To do this we still need some Lisp coding
as an interface to the GCL socket functions. Perhaps this is
possible using the $Lisp package call like this::

Creates a new two-way stream to handle an individual incoming
connection to STREAM, which must have been created with the SOCKET
function with the SERVER keyword set. ACCEPT should only be
invoked when LISTEN on STREAM returns T. If the STREAM was
created with the DAEMON keyword set in the call to SOCKET, ACCEPT
is unnecessary and will be called automatically as needed.

Function: LISTEN (&optional (stream standard-input))

Package:LISP

Returns T if a character is available on STREAM; NIL otherwise.
This function does not correctly work in some versions of GCL
because of the lack of such mechanism in the underlying operating
system.

Function: COPY-STREAM (in-stream out-stream)

Package:SI

GCL specific: Copies IN-STREAM to OUT-STREAM until the end-of-file
on IN- STREAM.

socketServer(8085,server$LHTTPD)
>> System error:
invalid number of arguments: 2

If this worked, a new web server on port 8085 would be launched
on the axiom-developer.org server. That would cause the Save
or refresh of this page to appear to hang (until the AXIOMsys
process is aborted by the system time-out) and this page would
then appear to be broken.

Unfortunately (or fortunately for readers of this page) we still
have some debugging to do.