Copyright (c) 2001, Junzo SATO. All rights reserved.
June 6th 2001
The author developed a Java class MathSocketTerminal to enable Mathematica to be able to send and receive data via TCP/IP socket. This class is loaded by Mathematica. Cache' database runs on a remote computer. The Java application package RelayStationArgs were built too. It runs on the remote computer so that it can relay packets between MathSocketTerminal's socket and Cache' telnet port.
J/Link is loaded and installed.
![[Graphics:Images/CacheTelnet_gr_1.gif]](Images/CacheTelnet_gr_1.gif)
![[Graphics:Images/CacheTelnet_gr_2.gif]](Images/CacheTelnet_gr_2.gif)
The communication tool MathSocketTerminal is loaded. An object of this class is constructed.
![[Graphics:Images/CacheTelnet_gr_4.gif]](Images/CacheTelnet_gr_4.gif)
SocketListener is a class which can receive TCP/IP packets. Incoming data is read and transferred to Mathematica by evaluating pre-installed handler.
![[Graphics:Images/CacheTelnet_gr_6.gif]](Images/CacheTelnet_gr_6.gif)
The handler simply prints received string in this example.
![[Graphics:Images/CacheTelnet_gr_8.gif]](Images/CacheTelnet_gr_8.gif)
![[Graphics:Images/CacheTelnet_gr_9.gif]](Images/CacheTelnet_gr_9.gif)
![[Graphics:Images/CacheTelnet_gr_11.gif]](Images/CacheTelnet_gr_11.gif)
![[Graphics:Images/CacheTelnet_gr_12.gif]](Images/CacheTelnet_gr_12.gif)
![[Graphics:Images/CacheTelnet_gr_13.gif]](Images/CacheTelnet_gr_13.gif)
RelayStation's server port on a remote computer is opened.
Because GUI for RelayStation was omitted for efficiency, RelayStation in RelayStationArgs is launched by command: java RelayStation.RelayStation
Connection to the RelayStation is established.
![[Graphics:Images/CacheTelnet_gr_15.gif]](Images/CacheTelnet_gr_15.gif)
Cache' telnet server requests login password at the very first of the session.
![[Graphics:Images/CacheTelnet_gr_17.gif]](Images/CacheTelnet_gr_17.gif)
![[Graphics:Images/CacheTelnet_gr_19.gif]](Images/CacheTelnet_gr_19.gif)
A word "Tokyo Prefecture" in Japanese is set.
![[Graphics:Images/CacheTelnet_gr_21.gif]](Images/CacheTelnet_gr_21.gif)
Inside Cache' unicode version, the word is stored as three unicode characters.
![[Graphics:Images/CacheTelnet_gr_25.gif]](Images/CacheTelnet_gr_25.gif)
![[Graphics:Images/CacheTelnet_gr_28.gif]](Images/CacheTelnet_gr_28.gif)
![[Graphics:Images/CacheTelnet_gr_31.gif]](Images/CacheTelnet_gr_31.gif)
![[Graphics:Images/CacheTelnet_gr_33.gif]](Images/CacheTelnet_gr_33.gif)
The namespace is changed from USER to ZIP by command:
zn "ZIP"
![[Graphics:Images/CacheTelnet_gr_35.gif]](Images/CacheTelnet_gr_35.gif)
The command:
do ##class(%Library.ResultSet).RunQuery("Zip.ZipTable","getTown","1940032")
runs query method getTown(zip7) in the class Zip.ZipTable with a string argument zip7 = "1940032"
It returnes prefecture, city, and town in database.
![[Graphics:Images/CacheTelnet_gr_38.gif]](Images/CacheTelnet_gr_38.gif)
The command:
do ##class(%Library.ResultSet).RunQuery("Zip.ZipTable","getZipCode","“Œ‹ž“s","’¬“cŽs")
runs query getZipCode(kanjiPref, kanjiCity) in the class Zip.ZipTable with string arguments: kanjiPref = "“Œ‹ž“s", kanjiCity = "’¬“cŽs". It returns town names.
![[Graphics:Images/CacheTelnet_gr_44.gif]](Images/CacheTelnet_gr_44.gif)
![[Graphics:Images/CacheTelnet_gr_48.gif]](Images/CacheTelnet_gr_48.gif)
![[Graphics:Images/CacheTelnet_gr_49.gif]](Images/CacheTelnet_gr_49.gif)
![[Graphics:Images/CacheTelnet_gr_50.gif]](Images/CacheTelnet_gr_50.gif)
![[Graphics:Images/CacheTelnet_gr_52.gif]](Images/CacheTelnet_gr_52.gif)