Enif's server mode is activated by calling Enif with the command line option ``-S port'' (where port is the number of the TCP/IP port which is to be used by the server). The only difference, compared to running Enif not in server mode, is that this option will install an Enif TCP/IP server configurable object as a child object of the primary Enif instance. This server object binds itself to the specified TCP/IP port and waits for client programs to open a connection.
When a client opens a connection, an Enif socket object is created as a child of the server object and a communication stream is established between the external client program and the corresponding socket object. When created, this object only defines the standard parameters needed for all objects (such as name, description, group filters, ...), leaving it up to the client program to create additional parameters as needed.
The client program can now send commands to Enif which then will be executed within Enif and the result will be sent back to the client. The result always ends either with positive or negative acknowledge, usually ``OK'' to indicate a successful command, respectively ``KO'' to indicate that the command could not be executed correctly.
The complete list of Enif server commands along with detailed technical specifications can be found in . Here, we will just mention some of the more important ones:
Besides the above server commands, the server also accepts the standard parameter specification commands which we already encountered in an earlier section of this paper, namely:
Having learned about the Enif server commands, let's try them out now. Even without having access to a specific Enif client program, it is possible to do this using the standard telnet program.
To do this, just start Enif in server mode using e.g. port 9090 with the command ``enif -S 9090''. Now, from a unix shell or CMD window, you can contact the Enif server with the command ``telnet localhost 9090'' and try out some of the above commands.
The first example just changes the current view from its current setting to the coordinate window (-1,-1,1,1). To do this, a Box type parameter named view is created and its send group is set to $CurrentView/, i.e. the receive group of the corresponding system parameter. When we then change the value of the parameter view to ``-1,-1,1,1'', Enif's parameter grouping will propagate a send group signal which is caught by the $CurrentView system parameter, which causes Enif's view to be changed accordingly.
%telnet localhost 9090 Trying 127.0.0.1... Connected to localhost (127.0.0.1). Escape character is '^]'. OK new Box view OK view : $CurrentView/ OK view= -1,-1,1,1 OK exit Connection closed by foreign host. %
The second example contacts the enif server to generate a list of all links having an auto volume of more than 3000, sorted according to decreasing link volumes. To do this, a link expression parameter named linkval and a link selector parameter named linksel are created and their values are set to the desired expressions. The check command is not absolutely necessary, but it would show if the specified expression would not be valid (e.g. if the current scenario would not have an auto assignment). The eval command, finally, is used to evaluate the expression linkval by iterating through all links selected in selector linksel and the corresponding results are output:
% telnet localhost 9090 Trying 127.0.0.1... Connected to localhost (127.0.0.1). Escape character is '^]'. OK new Expression linkval Links OK new Selector linksel Links OK linkval = volau,volad,timau,speedau OK check linkval OK linksel = volau>3000,-volau OK eval linkval linksel 609-608;3329.708;55;2.508259;8.133132 458-59;3209;0;1.2;10 705-713;3140.356;23.07692;0.617797;11.65431 611-610;3132.645;55;2.741341;10.06806 665-674;3105.219;0;0.811095;23.67171 668-665;3105.219;0;1.066585;12.37595 669-668;3105.219;0;1.308991;12.37595 516-608;3035.614;29.79895;0.454977;26.37496 517-516;3035.614;29.79895;0.432228;26.37496 607-606;3027.583;159.174;1.369371;10.07762 610-609;3016.525;55;1.423182;11.38294 OK exit Connection closed by foreign host. %
These two little examples using telnet should already give you an idea on the principles Enif's server is built upon. We now turn our attention to SEnC, a simple Enif client program which processes server commands that are read sequentially from given input files.