Distributed Processing

The basis for distributed processing in under Unix is supplied by the sockets module, which exports the functions defined below.

socketpCompiler
\begin{arguments}
\item[obj] An object
\end{arguments}
If obj is a socket returns t, otherwise ().

make-listenerCompiler Allocates a fresh listener object.

make-socketCompiler Allocates a fresh socket object. Note that this function is almost never called.

listener-idCompiler
\begin{arguments}
\item[Listener] a listener
\end{arguments}
Returns a pair, whose car field contains a symbol naming the local host and whose cdr field is a port number on that host identified with the listener.

listenCompiler
\begin{arguments}
\item[listener] a listener
\end{arguments}
Listens on the port number returned by listener-id applied to listener and returns socket when a connection is established.

connectCompiler
\begin{arguments}
\item[pair] A pair identifying a listening port on a remote machine
\end{arguments}
The pair contains the information returned by listener-id and makes a connection to the named machine on the specified port, returning socket which is the handle on the established connection bewteen the two processes.

close-listenerCompiler
\begin{arguments}
\item[listener] a listener
\end{arguments}
Changes internal state of listener so that it can no longer be used for listening.

close-socketCompiler
\begin{arguments}
\item[socket] a socket
\end{arguments}
Flushes all pending data related to socket and changes the internal state of socket so that it is no longer readable or writable.

socket-readable-pCompiler
\begin{arguments}
\item[socket] a socket.
\end{arguments}
If there is data available for reading from socket, returns t, otherwise ().

socket-writable-pCompiler
\begin{arguments}
\item[socket] A socket.
\end{arguments}
If data can be written to socket, returns t, otherwise ().

Figure [*] is two scripts of a simple example of establishing a socket connection and a dialogue across the connection

Currently socket-read and socket-write are used for input and output. If you are comminicating with non-processes then you should use format/print and scan/input. Read, for various reasons cannot be used.

Figure: Example socket based communication
machine-1 machine-2
eulisp:0:root!0> (!> standard)
Loading module 'standard'
Loading module 'extras'
Loaded 'extras'
Loaded 'standard'
eulisp:0:standard!0< standard

eulisp:0:standard!1> (import sockets)
eulisp:0:standard!1< ()

eulisp:0:standard!2> (setq s
   (connect '(machine-2 . 1236)))

eulisp:0:standard!2< #socket(3,3)

eulisp:0:standard!3> (socket-read s)
eulisp:0:standard!3< 1

eulisp:0:standard!4> (socket-write s 2)
eulisp:0:standard!4< 2
eulisp:0:root!0> (!> standard)
Loading module 'standard'
Loading module 'extras'
Loaded 'extras'
Loaded 'standard'
eulisp:0:standard!0< standard

eulisp:0:standard!1> (import sockets)
eulisp:0:standard!1< ()

eulisp:0:standard!2> (setq l
   (make-listener))

eulisp:0:standard!2< #listener(3,1)

eulisp:0:standard!3> (listener-id l)
eulisp:0:standard!3< (machine-2 . 1236)

eulisp:0:standard!4> (setq s (listen l))
eulisp:0:standard!4< #socket(4,3)

eulisp:0:standard!5> (socket-write s 1)
eulisp:0:standard!5< 1

eulisp:0:standard!6> (socket-read s )
eulisp:0:standard!6< 2



Subsections