view extra/soctcl/README @ 12671:20e8aca47b2c octave-forge

prepare for release
author cdf
date Mon, 17 Aug 2015 10:19:39 +0000
parents 358a42e95349
children
line wrap: on
line source

Enclosed is a socket implementation of a tcl-octave connection.

You will need the following:

   tcl/tk (http://tcl.sourceforge.net)
   BLT (http://sourceforge.net/projects/blt)
   octave (http://www.octave.org)
   octave-forge (http://octave.sourceforge.net)

If you are using Windows, you can get a binary distributions
from the following:

   tcl/tk (http://activestate.com/Products/ActiveTcl/)
   BLT (http://sourceforge.net/projects/blt)
   octave+octave-forge (http://octave.sourceforge.net)

This directory should be somewhere in your Tcl path, either
because you unpacked the archive in the Tcl lib directory or
because you set auto_path to include this directory in your
Tcl source file.  If you are trying to install from SVN,
use release.sh to generate the archive (soctcl#.#.zip and/or
soctcl#.#.tar.gz) which you can then unpack into the Tcl lib
directory.

Start the server:

   # start the server
   # !!! WARNING !!! Very insecure!!! The link allows arbitrary octave
   # commands to be executed and octave allows arbitrary system commands!!!
   # At present connections can come from one host only (127.0.0.1).  I
   # don't know how easy this is to spoof by forging the IP packet header.
   octave
   server(3132);
   ## if want to run the client remotely, use
   # server(3132,'hostid')
   ## where hostid is the name or the four part numeric host 
   ## address of the client.

Test the client:

   $ wish
   package require BLT
   package require octave
   octave connect localhost:3132 ;# localhost:3132 is the default

   # evaluate a command in octave
   octave eval { a = [1,2,3,4,5] }

   # return a result from octave
   octave recv x a(2)
   octave sync
   puts $::x

   # return a result as a BLT vector
   blt::vector ::y
   octave recv y a(2:4)
   octave sync
   puts $::y(:)

   # grab a matrix as a tcl image
   octave eval { [x,y] = meshgrid(linspace(-8,8,40)); }
   octave eval { sample = sinc(sqrt(x.^2+y.^2)); }
   octave eval { colormap(ocean) }
   image create photo sample
   octave image sample imagesc(sample)
   octave sync ;# wait for photo to arrive
   pack [button .b -image sample]

   # close the connection
   octave close

   exit

   # I haven't yet written
   # octave capture command ;# show the output of the command
   # octave console         ;# open up a direct console to this interpreter

Read demo/matrix.tcl for a tutorial.  With the octave server still running, you
can play with it using the following command:

   demo/matrix.tcl  ?host:port

Read octave.txt for a description of the commands available.

Read listen.txt from octave-forge/main/miscellaneous for a description
of the protocol.

Paul Kienzle
2003-07-15