From: <pki...@us...> - 2008-11-04 21:43:14
|
Revision: 5403 http://octave.svn.sourceforge.net/octave/?rev=5403&view=rev Author: pkienzle Date: 2008-11-04 21:41:58 +0000 (Tue, 04 Nov 2008) Log Message: ----------- replace references for misc/listen() with server() Modified Paths: -------------- trunk/octave-forge/extra/soctcl/README trunk/octave-forge/extra/soctcl/demo/matrix.tcl trunk/octave-forge/extra/soctcl/demo/octsync.tcl trunk/octave-forge/extra/soctcl/doc/README trunk/octave-forge/extra/soctcl/doc/octave.txt trunk/octave-forge/main/miscellaneous/INDEX trunk/octave-forge/main/miscellaneous/src/server.cc Added Paths: ----------- trunk/octave-forge/main/miscellaneous/doc/server.txt Removed Paths: ------------- trunk/octave-forge/main/miscellaneous/doc/listen.txt Modified: trunk/octave-forge/extra/soctcl/README =================================================================== --- trunk/octave-forge/extra/soctcl/README 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/extra/soctcl/README 2008-11-04 21:41:58 UTC (rev 5403) @@ -30,9 +30,9 @@ # 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 - listen(3132); + server(3132); ## if want to run the client remotely, use - # listen(3132,'hostid') + # server(3132,'hostid') ## where hostid is the name or the four part numeric host ## address of the client. Modified: trunk/octave-forge/extra/soctcl/demo/matrix.tcl =================================================================== --- trunk/octave-forge/extra/soctcl/demo/matrix.tcl 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/extra/soctcl/demo/matrix.tcl 2008-11-04 21:41:58 UTC (rev 5403) @@ -8,7 +8,7 @@ # octave and octave-forge installed. # # demo$ octave -# > listen(3132) +# > server(3132) # # This starts an octave listening daemon. To remove it you will have # to use kill directly after using ps aux | grep octave to find its pid. Modified: trunk/octave-forge/extra/soctcl/demo/octsync.tcl =================================================================== --- trunk/octave-forge/extra/soctcl/demo/octsync.tcl 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/extra/soctcl/demo/octsync.tcl 2008-11-04 21:41:58 UTC (rev 5403) @@ -3,7 +3,7 @@ # usage: octsync.tcl ?port # # This is a lowlevel test of the octave server synchronization -# response time. It uses the octave listen() protocol directly +# response time. It uses the octave server() protocol directly # rather than going through the octcl package. Any delays seen # are directly due to tcl and to octave's implementation of sockets # and not any special handling I'm doing in octave.tcl. Modified: trunk/octave-forge/extra/soctcl/doc/README =================================================================== --- trunk/octave-forge/extra/soctcl/doc/README 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/extra/soctcl/doc/README 2008-11-04 21:41:58 UTC (rev 5403) @@ -30,9 +30,9 @@ # 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 - listen(3132); + server(3132); ## if want to run the client remotely, use - # listen(3132,'hostid') + # server(3132,'hostid') ## where hostid is the name or the four part numeric host ## address of the client. @@ -82,7 +82,7 @@ Read octave.txt for a description of the commands available. -Read listen.txt from octave-forge/main/miscellaneous for a description +Read server.txt from octave-forge/main/miscellaneous for a description of the protocol. Paul Kienzle Modified: trunk/octave-forge/extra/soctcl/doc/octave.txt =================================================================== --- trunk/octave-forge/extra/soctcl/doc/octave.txt 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/extra/soctcl/doc/octave.txt 2008-11-04 21:41:58 UTC (rev 5403) @@ -17,14 +17,14 @@ able to capture the output of an octave command. Please read demo/matrix.tcl for a sample octave.tcl application. -Please read octave-forge/main/miscellaneous/listen.doc for a description +Please read octave-forge/main/miscellaneous/server.txt for a description of the protocol. To connect to octave, you must first start run octave as a server process listening to connections on a port: $ octave - > listen(3132) + > server(3132) When it receives a new connection, octave forks and lets the child process interpret the octave commands. Only after octave is listening @@ -226,7 +226,7 @@ Octave Reference ---------------- -listen(port) +server(port) listen for connections on the given port. send('expression') @@ -252,7 +252,7 @@ to the port you select. There is a very simplistic host-based access scheme implemented. -If you specify listen(port,hostid) where hostid is a string +If you specify server(port,hostid) where hostid is a string containing the four part numeric host address, then only connections from that host are accepted. By default hostid is 127.0.0.1, so only localhost connections are allowed. I have no idea how easy Modified: trunk/octave-forge/main/miscellaneous/INDEX =================================================================== --- trunk/octave-forge/main/miscellaneous/INDEX 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/main/miscellaneous/INDEX 2008-11-04 21:41:58 UTC (rev 5403) @@ -17,3 +17,4 @@ zigzag csvconcat csvexplode + server Deleted: trunk/octave-forge/main/miscellaneous/doc/listen.txt =================================================================== --- trunk/octave-forge/main/miscellaneous/doc/listen.txt 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/main/miscellaneous/doc/listen.txt 2008-11-04 21:41:58 UTC (rev 5403) @@ -1,118 +0,0 @@ -You can talk to octave directly from other environments over the tcp/ip. -The protocol is not sophisticated. - -Here is what you can send to octave: - -!!!x length command - - evaluate command in octave. - length is a 32-bit network order integer. - command is a string (without zero-terminator). - -!!!m length name - - send matrix back to client. - length is a 32-bit network order integer. - name is a string (without zero-terminator). - - I don't use the !!!m command to the server because it is the same as - - !!!x send('name', matrix expression) - - The latter is much more useful because you don't have to name - the data that you are sending across. - -!!!n length namelen name command - - *** Not implemented *** - Evaluate the command in the namespace. This needs a lookup table - Map<string,symbol_table> namespace - and a command - evalin(symbol_table,command) - The function evalin pushes the given symbol table onto curr_sym_tab, - evaluates the command then pops the symbol table. - -Here is what you will receive from octave: - -!!!m length rows columns namelength name data - - recieve matrix from server. - length,rows,columns,namelength are 32-bit network order integers. - name is a string (without zero-terminator). - data is an array of rows*columns server order double values. - - This is sent in response to a !!!m matrix request or a - send('name',matrix) command. - - The first thing I do when I open a connection is request a matrix - containing 1.0. If the result is not 1.0, I know that I need to - swap the data to convert from server order to client order doubles. - -!!!s length strlen namelen name str - - receive string from server. - length, strlen, namelen are 32-bit network order integers. - name is a string (without zero-terminator). - str is a string (without zero-terminator). - - This is sent in response to a send('name',string) command. - -!!!x length str - - evaluate string in client. - length is a 32-bit network order integer. - str is a string (without zero-terminator). - - This is sent in response to a send('str'). The contents of str - are completely arbitrary (and may indeed contain binary data). It is - up to the client to decide how they want to interpret these strings. - -!!!e length error - - receive error from octave. - length is a 32-bit network order integer. - error is a string (without zero-terminator). - - This is sent in response to a !!!x command which produced an error. - -Composite values can be decomposed into their constituent parts. E.g., - structures: - for [v,k]=x, send([name,'.',k],v); end - complex arrays: - send([name,'.real'],real(x)); - send([name,'.imag'],imag(x)); - sparse arrays: - [v,i,j] = spfind(x); - send([name,'.i'],i); - send([name,'.j'],j); - send([name,'.v'],v); - cell arrays: - [nr,nc]=size(x); - for r=1:nr, for c=1:nc, send([name,sprintf('.%d.%d',r,c)],x{r,c}); end - -Note that the communication is completely asynchronous. I have a tcl client -that processes server responses via fileevent. That means that responses from -octave are not processed until tcl enters its event loop. - -To be sure that octave has processed a command I follow that command with a -synchronization sequence: - - set sync[incr syncid] 1 - octave eval "send('unset sync$syncid')" - vwait sync$syncid - -In practice it is more complicated than that because I allow the -syncronization command to time out just in case octave crashed out from -underneath me, but the idea is the same. - -Using sockets gives you platform independence and network transparency, -which is a big win. The only caveat is that winsock is slow. The best I -can do with dedicated winsock code on my machine is .3 seconds to transfer -a 1 Mb message. Under tcl/tk, it was closer to 1 second IIRC. A memory -copy of the same size took less than 0.06 seconds IIRC. - -That is why I'm working on a way to embed octave into tcl. Hopefully -it will be easy to embed in other environments as well. - -Paul Kienzle -2003 Copied: trunk/octave-forge/main/miscellaneous/doc/server.txt (from rev 5383, trunk/octave-forge/main/miscellaneous/doc/listen.txt) =================================================================== --- trunk/octave-forge/main/miscellaneous/doc/server.txt (rev 0) +++ trunk/octave-forge/main/miscellaneous/doc/server.txt 2008-11-04 21:41:58 UTC (rev 5403) @@ -0,0 +1,118 @@ +You can talk to octave directly from other environments over the tcp/ip. +The protocol is not sophisticated. + +Here is what you can send to octave: + +!!!x length command + + evaluate command in octave. + length is a 32-bit network order integer. + command is a string (without zero-terminator). + +!!!m length name + + send matrix back to client. + length is a 32-bit network order integer. + name is a string (without zero-terminator). + + I don't use the !!!m command to the server because it is the same as + + !!!x send('name', matrix expression) + + The latter is much more useful because you don't have to name + the data that you are sending across. + +!!!n length namelen name command + + *** Not implemented *** + Evaluate the command in the namespace. This needs a lookup table + Map<string,symbol_table> namespace + and a command + evalin(symbol_table,command) + The function evalin pushes the given symbol table onto curr_sym_tab, + evaluates the command then pops the symbol table. + +Here is what you will receive from octave: + +!!!m length rows columns namelength name data + + recieve matrix from server. + length,rows,columns,namelength are 32-bit network order integers. + name is a string (without zero-terminator). + data is an array of rows*columns server order double values. + + This is sent in response to a !!!m matrix request or a + send('name',matrix) command. + + The first thing I do when I open a connection is request a matrix + containing 1.0. If the result is not 1.0, I know that I need to + swap the data to convert from server order to client order doubles. + +!!!s length strlen namelen name str + + receive string from server. + length, strlen, namelen are 32-bit network order integers. + name is a string (without zero-terminator). + str is a string (without zero-terminator). + + This is sent in response to a send('name',string) command. + +!!!x length str + + evaluate string in client. + length is a 32-bit network order integer. + str is a string (without zero-terminator). + + This is sent in response to a send('str'). The contents of str + are completely arbitrary (and may indeed contain binary data). It is + up to the client to decide how they want to interpret these strings. + +!!!e length error + + receive error from octave. + length is a 32-bit network order integer. + error is a string (without zero-terminator). + + This is sent in response to a !!!x command which produced an error. + +Composite values can be decomposed into their constituent parts. E.g., + structures: + for [v,k]=x, send([name,'.',k],v); end + complex arrays: + send([name,'.real'],real(x)); + send([name,'.imag'],imag(x)); + sparse arrays: + [v,i,j] = spfind(x); + send([name,'.i'],i); + send([name,'.j'],j); + send([name,'.v'],v); + cell arrays: + [nr,nc]=size(x); + for r=1:nr, for c=1:nc, send([name,sprintf('.%d.%d',r,c)],x{r,c}); end + +Note that the communication is completely asynchronous. I have a tcl client +that processes server responses via fileevent. That means that responses from +octave are not processed until tcl enters its event loop. + +To be sure that octave has processed a command I follow that command with a +synchronization sequence: + + set sync[incr syncid] 1 + octave eval "send('unset sync$syncid')" + vwait sync$syncid + +In practice it is more complicated than that because I allow the +syncronization command to time out just in case octave crashed out from +underneath me, but the idea is the same. + +Using sockets gives you platform independence and network transparency, +which is a big win. The only caveat is that winsock is slow. The best I +can do with dedicated winsock code on my machine is .3 seconds to transfer +a 1 Mb message. Under tcl/tk, it was closer to 1 second IIRC. A memory +copy of the same size took less than 0.06 seconds IIRC. + +That is why I'm working on a way to embed octave into tcl. Hopefully +it will be easy to embed in other environments as well. + +Paul Kienzle +2003 Modified: trunk/octave-forge/main/miscellaneous/src/server.cc =================================================================== --- trunk/octave-forge/main/miscellaneous/src/server.cc 2008-11-04 21:34:26 UTC (rev 5402) +++ trunk/octave-forge/main/miscellaneous/src/server.cc 2008-11-04 21:41:58 UTC (rev 5403) @@ -727,7 +727,7 @@ } #if 0 - unwind_protect::begin_frame("Flisten"); + unwind_protect::begin_frame("Fserver"); unwind_protect_bool (buffer_error_messages); buffer_error_messages = true; #endif @@ -799,7 +799,7 @@ closesocket(sockfd); end_sockets(); #if 0 - unwind_protect::run_frame("Flisten"); + unwind_protect::run_frame("Fserver"); #endif return ret; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |