Before we try and understand the program, let us run it to see if it works!
The PLANStart tool is provided as a means to inject PLAN programs into the network directly from the command line. It is invoked by using the Java interpreter. Typing 'java PLANStart' gives you the usage of PLANStart :
% java PLANStart usage : java PLANStart [-v] [-p port] <code> <RB> <router IPv4 2address>
The code argument is the name of the file that contains the PLAN program. The RB argument specifies the initial amount of resource to hand to the packet going into the network. The last argument specifies the host that is to be the entry point into the network.
-v option produces a verbose output. The
-p option allows
you to specify the outgoing TCP port, much as was described above for the
active router. This also serves to set the port portion of the identity for
the PLANStart program should the thisHost local service routine be
invoked during the initial invocation (see the ping example below). Note
that PLANStart and ARMain should use the same port number, or they will not
be able to communicate properly.
Suppose that you typed the Hello world program into a file called Helloworld.plan, and that you want to use an active host called ``MyActiveNode'' as the network entry point. Let us also give this program an initial resource amount of 10. Now type :
% java PLANStart Helloworld.plan 10 MyActiveNode
The program waits for you to give it the next input : the initial invocation. Recall that a PLAN program is a list of definitions - when the program arrives at an active host, you must specify which function to start executing and with what arguments. In the case of the Hello world program, there is only one function to execute, and it takes no parameters, so you type :
Out comes the response :
IPv4 : MyActiveHost.domain.name/some.ip.address says : Hello world!
Notice that you must press Ctrl-C to get back to the command line. This is because the PLANStart tool, after injecting the program into the network, waits for possible responses. Since it does not know how many responses to expect, it has to wait indefinitely until told explicitly to stop.
As a final note, had you included the -v option, you would have seen the following:
% java PLANStart Helloworld.plan 10 MyActiveNode Checking for parse errors in source code ... Binding Top Environ ... Getting Initial Resource ... Getting Address of Active Router ... Parsing the initial invocation ...
This is useful in debugging errors. At this point you would type the initial invocation, as noted above.