$VULCAN/src/socket.scm
defines the classes <msocket>
and <mserver>
. The methods associated with this class are:
(mstart (self <msocket>)) (mstart (self <mserver>)) (close (self <msocket>)) (read-socket (self <msocket>)) // read next expression from // the socket // write to a socket always includes an end of line character (write-socket (self <msocket>) expression) // use ``~a'' when writing the result of the expression (write-socket-s (self <msocket>) expression) // uset ``~s'' when writing the result of the expression (write-socket-lf (self <msocket>) expression) // send linefeed character (input-ready? (self <msocket>))To start a socket you have to specify the
host
and port
associated with it. For example,
(set! ms (mstart (make <msocket> host: ``vulcan'' port: 3333)))contacts
Vulcan
on port 3333. If instead you want to open a server in the current host on port 3333, you will do
(set! ms (mstart (make <mserver> port: 3333)))In the current implementation, only one client can connect to a server. The file
$VULCAN/src/dispatcher.scm
illustrates how to use sockets to define an eval loop service.