isCOBOL Application Server : isCOBOL File Server : isCOBOL File Server usage
isCOBOL File Server usage
The File Server daemon can be started with the following command:
iscserver -fs [-c config_file] [-fsport FSport] [-hostname host] [-as] [-port ASport] [-force]
Setting iscobol.as.fileserver (boolean) to true in the configuration produces the same effect as using the -fs option while setting iscobol.as.appserver (boolean) to true in the configuration produces the same effect as using the -as option.
The following command starts the File Server on the local pc on the default port 10997:
iscserver -fs
A correct startup will produce an ouptut similar to this:
Application Server (file services) started and listening on port 10997
You can start both the Application Server and the File Server at the same time with the command:
iscserver -fs -as
Starting the Application Server in addition to the File Server allows you to connect the Administration Panel (see Format 5 of the isCOBOL Client command) and monitor the active connections to the File Server.
Both services can start on different ports than the defaults. Use the -fsport and -port options to control the port where the services will be listening. The following command, for example, starts the File Server on the port 1234 and the Application Server on the port 1235:
iscserver -fs -fsport 1234 -as -port 1235
The File Server host name and port can also be set in the configuration file, as shown below.
Config_file should include the standard configuration, that is the same for every client. See Usage of isCOBOL Client for information about how to use a customized client configuration.
Client-side Configuration
There are two ways a program can use a remote file on the File Server.
1. By specifying server name and port in the file name with the ISF protocol, or
2. By using the "com.iscobol.io.DynamicRemote" class as file handler
The ISF protocol
It is possible to specify File Server connection information in the physical file name through the URL syntax as follows:
isf://hostname[:port]:path/to/file
Where
hostname is the server name or IP address where the File Server is listening
port is the port where the File Server is listening. If omitted, the port specified by iscobol.file.remote.port * (whose default value is 10997) is used
path/to/file is the name of the remote file to open. It can be either a full path, a relative path or just the file name. If omitted, the root folder is assumed, so a path like "isf://localhost:" is equivalent to "isf://localhost:/".
The URL can be put entirely in the file name or can be built by combining the FILE-PREFIX setting and the file name.
When the FILE-PREFIX setting includes paths starting with "isf://", multiple paths must be separated by a line feed character, e.g.
iscobol.file.prefix=isf://192.168.0.1:/usr/data\nC:\\Temp
The above setting specifies two paths for the FILE-PREFIX:
1. the folder /usr/data on the remote server whose IP is 192.168.0.1 where the File Server is listening
2. the local folder C:\Temp
The following code snippets show two ways to open FILE1 through the File Server listening on 192.168.0.1 on the default port. The File Server will search in the /usr/data folder on the server:
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT FILE1 ASSIGN TO "isf://192.168.0.1:/usr/data/FILE1"
                  ORGANIZATION INDEXED
                  ACCESS DYNAMIC
                  RECORD KEY FILE1-KEY.
       
       FILE SECTION.
       FD FILE1.
       01 FILE1-RECORD.
          03 FILE1-KEY  PIC 9(3).
          03 FILE1-DATA PIC X(50).
       
       PROCEDURE DIVISION.
       MAIN.
           OPEN INPUT FILE1.
 
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT FILE1 ASSIGN TO "FILE1"
                  ORGANIZATION INDEXED
                  ACCESS DYNAMIC
                  RECORD KEY FILE1-KEY.
       
       FILE SECTION.
       FD FILE1.
       01 FILE1-RECORD.
          03 FILE1-KEY  PIC 9(3).
          03 FILE1-DATA PIC X(50).
       
       PROCEDURE DIVISION.
       MAIN.
           SET ENVIRONMENT "file.prefix" TO "isf://192.168.0.1:/usr/data".
           OPEN INPUT FILE1.
The DynamicRemote class
In order to access remote files, client programs can assign their files to the "com.iscobol.io.DynamicRemote" class. In the configuration, it’s also possible to use the alias "remote".
The class can be assigned in the SELECT statement. See FILE-CONTROL Paragraph, rule 35 for information about how to assign a file to a specific class.
For example, the following sequential file will be opened through the File Server, regardless of the file name that the program puts in the ARC-NAME variable:
SELECT ARC ASSIGN TO ARC-NAME
           ORGANIZATION LINE SEQUENTIAL
           CLASS "com.iscobol.io.DynamicRemote"
           .
The assignment can be done also through the following configuration properties:
For example, the following configuration entry causes all the indexed files to be opened through the File Server:
iscobol.file.index=remote
Client programs are made aware of the File Server location through the configuration properties iscobol.file.remote.host * and iscobol.file.remote.port *.
Since the full-path of the file is built client-side by the runtime before sending the i/o request to the File Server, iscobol.file.prefix must be set in the client configuration and must specify the directories on the server where files will be opened. If the server operating system uses a different file separator than the client, the property iscobol.file.prefix_separator must be set in the client configuration as well.
The following client configuration, for example, handles only indexed files remotely on the Linux server whose IP is 192.168.0.1 assuming that the File Server is listening on the default port:
iscobol.file.index=remote
iscobol.file.remote.host=192.168.0.1
iscobol.file.prefix=/usr/data
iscobol.file.prefix_separator=/
The following more complex sample configuration, instead, handles indexed, sequential and relative files remotely on the Linux server whose IP is 192.168.0.1 having the File Server listening on the port 12345:
iscobol.file.index=remote
iscobol.file.sequential=remote
iscobol.file.linesequential=remote
iscobol.file.relative=remote
iscobol.file.remote.host=192.168.0.1
iscobol.file.remote.port=12345
iscobol.file.prefix=/usr/data
iscobol.file.prefix_separator=/
User Authentication
If iscobol.as.authentication * is set to 2 in the server configuration, iscobol.user.name and iscobol.user.password must be set client side in order to specify login information.