PreviousUsing Panels V2 Advanced TopicsNext

Chapter 14: Using the Client/Server Binding

This chapter shows you how the Client/Server Binding works and then describes how to connect your user programs to the generic client/server modules.

14.1 Introduction

The Client/Server Binding enables you to implement a client/server architecture with a Dialog System front end using the Micro Focus Common Communications Interface component (CCI) "under the covers". The Client/Server Binding removes the requirement for you to include communications code in your application by providing two modules called mfclient and mfserver. These are generic modules which can be used to drive any application.

Based on information contained in a configuration file, the modules manage the communication and transfer of data between themselves and are able to interact with user-defined programs at each end of the link to process this data. mfclient is called by a user client program which handles the user interface, and mfserver calls a user server program which handles data access and business logic. However, as these user client and server programs are user-defined, they can do anything you require.

The user programs must use the copyfile mfclisrv.cpy, described in the section The mfclisrv.cpy Copyfile, to interact with the generic client/server modules.

A sample two-tier application, based on the Dialog System CUSTOMER demonstration, is available in the directory DialogSystem\demo\csbind of your installation directory. This sample application demonstrates how to use use the Client/Server Binding and is referred to throughout this chapter. For more information on the sample application please see the file csbind.txt installed in the DialogSystem\demo\csbind directory.

14.2 How the Client/Server Binding Works

This section illustrates how a two-tier application, created using the Client/Server Binding works.

The Client/Server Binding works by having a non­dedicated copy of mfserver running on the server tier; that is, mfserver communicates with any and all clients using an agreed server name. This mfserver module can be run with its built-in defaults since its only function is to receive the starting and ending communications from the client.

This process is illustrated in the next diagram, Figure 14-1. The flow of information illustrated in the diagram is explained below:

  1. The user's client program (custint) CALLs mfclient.

  2. The first time mfclient is called, it reads configuration information from the .cfg file.

  3. mfserver receives the connection request.

  4. mfserver spawns a secondary server for each client. The server name is internally generated, based on the name of the initial server with a numeric ID added (for example, mfserver01). Alternatively, you can specify a name in the configuration file.

  5. mfserver sends the secondary server name (mfserver01) back to mfclient and terminates the conversation.

  6. mfclient connects with the secondary server (mfserver01), passing parameters obtained from the configuration file via the LNK-PARAM-BLOCK. See the section The Client/Server Binding Configuration File.

  7. mfserver01 CALLs the user server program (custdata), passing the parameters received from mfclient via the Linkage Section.

  8. The first time the user server program (custdata) is called, it performs any application initialization code and exits the program. Control is returned to mfserver01.

    Flowchart

    Figure 14-1: Client/Server Binding

  9. mfserver01 returns control to mfclient.

  10. mfclient ensures contact has been established and returns control to the user client program (custint).

  11. In the user client program (custint), data associated with the user interface is mapped to areas assigned by mfclient within the Linkage Section.

  12. The user client program (custint) calls the user interface. up the screenset and CALLs Dialog System.

  13. The user enters input in the user interface (CUSTOMER).

  14. The user client program CALLs mfclient again to pass back the user-entered data (for example a Customer Code) and any other information required by the application server program (custdata) via the Linkage Section.

  15. mfclient passes the data to mfserver01 via its internal buffer.

  16. mfserver01 CALLs the user server program (custdata).

  17. The user server program (custdata) performs any appropriate data access and business logic and returns the results to mfserver01 via the Linkage Section.

  18. mfserver01 returns control to mfclient.

  19. mfclient passes the data back to the user client program (custint) via the Linkage Section.

  20. The user client program (custint) CALLs the user interface to display data and accept any new user input.

    Steps 14 thru 20 are repeated until the user exits the application.

  1. mfclient informs the base server (mfserver), that the secondary server (mfserver01) has terminated.

    This use of initial and secondary servers resolves several issues:

14.3 Connecting Your Programs to the Generic Modules

The following sections show you how to:

14.3.1 Connecting Your Client Application to mfclient

This section shows you how to connect your client program to the mfclient module, which handles communications with the server. The mfclient and mfserver modules pass information to each other via a parameter block described in the mfclisrv.cpy copyfile.

The modules also use the same parameter block to pass information to any user programs they have been requested to call in the configuration files. For details on the LNK-PARAM-BLOCK, see the section Connecting Your Server Application to mfserver.

To connect your client program calling the user interface, you must add code to pass parameters to mfclient.

To use the Client/Server Binding, your client program will need to include code similar to that below. This is an extract of the user interface program (custint.cbl) supplied with Dialog System to demonstrate how to use the Client/Server Binding.

$SET ANS85
 WORKING-STORAGE SECTION.
 COPY "MFCLISRV.CPY".
 LINKAGE SECTION.
* The following two copyfiles are used by Dialog System
* user interfaces to communicate with the COBOL program
* which calls the interface
 COPY "DS-CNTRL.V1".
 COPY "CUSTOMER.CPB".
 PROCEDURE DIVISION.
 CLIENT-CONTROL SECTION.
     PERFORM UNTIL END-CONNECTION
         CALL LNK-CLIENT USING LNK-PARAM-BLOCK
         EVALUATE TRUE
          WHEN START-CONNECTION
             SET ADDRESS OF DS-CONTROL-BLOCK TO LNK-CBLOCK-PTR
             SET ADDRESS OF CUSTOMER-DATA-BLOCK TO LNK-DBLOCK-PTR
             PERFORM SETUP-SCRNSET
             PERFORM CALL-DIALOG-SYSTEM
          WHEN END-CONNECTION
             EXIT PERFORM
          WHEN OTHER
             PERFORM CALL-DIALOG-SYSTEM
         END-EVALUATE
         IF CUSTOMER-EXIT-FLG-TRUE
            SET CLIENT-ENDING TO TRUE
         END-IF
     END-PERFORM.
 CLIENT-CONTROL-END.
     STOP RUN.

You can add code to enable client counting, handle error message displays yourself or handle asynchronous requests. For details, see the sections Connecting Your Client Program to mfclient and Connecting Your Server Program to mfserver.

14.3.2 Connecting Your Server Application to mfserver

This section shows you how to connect your server program, which performs data access and/or business logic, to the mfserver module which handles communications with the client. The mfclient and mfserver modules pass information to each other via a parameter block described in the mfclisrv.cpy copyfile. The modules also use the same parameter block to pass information to any user programs they have been requested to call in the configuration files.

The following information does not apply if you are using an existing application as your server program. For details on using the Client/Server Binding in that way, see the section Running a Client/Server Binding Application.

To use the Client/Server Binding:

This is shown below in the code extract of the server program (custdata.cbl) used to run the Client/Server Binding.

 LINKAGE SECTION.
 COPY "DS-CNTRL.V1".
 COPY "CUSTOMER.CPB".
 COPY "MFCLISRV.CPY".
 PROCEDURE DIVISION USING LNK-PARAM-BLOCK.
 CONTROLLING SECTION.
*---------------------------------------------------------------*
*  ASSOCIATE THE DIALOG SYSTEM COPYBOOKS WITH AREAS RESERVED
*  FOR THEM WITHIN LNK-PARAM-BLOCK
*---------------------------------------------------------------*
     SET ADDRESS OF DS-CONTROL-BLOCK TO LNK-CBLOCK-PTR.
     SET ADDRESS OF CUSTOMER-DATA-BLOCK TO LNK-DBLOCK-PTR.
     EVALUATE TRUE
      WHEN START-CONNECTION
         PERFORM PROGRAM-INITIALIZE
      WHEN OTHER
         PERFORM PROGRAM-BODY
     END-EVALUATE.
     EXIT PROGRAM.
 PROGRAM-INITIALIZE SECTION.
     OPEN I-O CUSTOMER-FILE.
 PROGRAM-BODY SECTION.
     MOVE CUSTOMER-C-CODE TO FILE-C-CODE
     READ CUSTOMER-FILE
     ..........
     PERFORM DERIVATIONS

You can add code to handle error message displays yourself. For details, see the section Connecting Your Server Program to mfserver.

14.3.3 Preparing a Communications Link

The Client/Server Binding controls the communications between your client and server programs based on the contents of the configuration file. That means there is no complicated communications programming for you to do.

To run the demonstration, use the appropriate configuration (.cfg) file unmodified. For your own application, you must copy and modify the contents of one of these configuration files. The configuration file is an ASCII text file containing parameters allowing you to specify key information such as:

For more details on using configuration files with the Client/Server Binding, see the section The Client/Server Binding Configuration File.


Notes:


14.4 Before Using the Client/Server Binding

You can use the client/server binding with an existing standalone application or an application architectured for client/server. For more information on using existing standalone applications, see the section Running a Client/Server Binding Application.

In either case, your application contains the following (examples of the supplied Dialog System demonstration programs are shown):


Two-tier Demo Program
Standalone Demo Program
User Interface CUSTOMER.gs (GUI)
COBOL code to call the interface custint.cbl usexsrv.cbl
COBOL code to perform data access and apply business logic custdata.cbl customer.cbl

You can use the client/server binding instead of creating your own middleware code. For this, you need to:

14.4.1 The mfclisrv.cpy Copyfile

The mfclient and mfserver modules pass information to each other via the parameter block defined in the copyfile mfclisrv.cpy. For example, the information includes addresses for the Dialog System screensetdata-block and ds-control-block. The modules also use this parameter block to pass information to any user programs they have been requested to call in the configuration files. The mfclisrv.cpy copyfile must be included in any of your COBOL programs which use the mfclient and mfserver modules.

The mfclisrv.cpy copyfile is installed in the SOURCE directory of your Net Express base installation directory.

14.4.2 The Client/Server Binding Configuration File

This section describes the configuration file for the client/server binding. This configuration file controls the behavior of the mfclient and mfserver modules as well as the communications link.

You create one or more configuration files for your application. You can have as many configuration files as your application requires, but each file must have a .cfg extension. If you do not supply a configuration filename yourself, the program will default to using the name mfclisrv.cfg. You do not need a configuration file, but if you do not supply one, the demonstration programs supplied with the client/server binding are run by default.

If your client/server application is incorrectly set up, any invalid entries found in the configuration file cause the programs reading them to terminate with a message displayed on the screen detailing the invalid entries.

These errors are also logged in the mfclisrv.log file, which is created in the current directory, or in the directory indicated by the MFLOGDIR environment variable. This enables a server which is not directly connected to a terminal to log messages regarding problems it encounters.

14.4.2.1 Possible Entries for the Configuration File

Below are possible entries for the mfclisrv.cfg configuration file. Entries are listed in alphabetical order. Any entries which you do not specify in your configuration file will assume the default values.

**********************************************************
* Micro Focus - Client/Server Module Configuration File
**********************************************************

[mf-clisrv]

cblksize=nnnn

PIC X(4) COMP-X [default:0]

Size of Dialog System control block.

clierrprog=xxxxxx

PIC X(128) [default:none]

Name of program to handle communication errors instead of mfclient. The name 'SAME' will use the calling program to handle any mfclient errors.

commsapi=xxxx

PIC X(4) [default:CCI]

API used for communications (CCI/NONE). The special entry 'NONE' can be used when developing two tier applications to allow testing to be undertaken on a single PC without any communications products.

Data is passed directly between mfclient and the user server program, bypassing mfserver and the communications requirement.

Note: This option cannot be used if an existing application is being deployed as the user server program.

compress=nnn

PIC 9(3) [default:000]

Compression routine indicator. The number indicates the name of the compression routine to be used, that is, 001 uses the routine CBLDC001. Zero indicates data compression will not be used.

dblksize=nnnn

PIC X(4) COMP-X [default:0]

Size of the user data block. When using the binding modules with Dialog System, this entry must match or be greater than the size of the Data Block generated by Dialog System. If the data fields used by the screenset are changed and the copyfile regenerated, change this entry to reflect the size of the new Data Block. When using multiple screensets, this entry should reflect the size of the largest screenset Data Block.

Note: Unpredictable results can occur if this entry is less than the actual size of the Data Block being used.

eblksize=nnnn

PIC X(4) COMP-X [default:0]

Size of optional Dialog System Event block.

machinename=

PIC X(34)

Name of the machine on which the server specified in the servername entry is located. This prevents the system searching for the first match of the defined name.

maxtrans=xxxx

PIC 99 [default:0]

Maximum transfer package size in Kilobytes. If the total buffer size exceeds this amount, the system will make multiple transfers of 'maxtrans' size until the total buffer is transferred. The accepted values are 1-62.

midconfig=xxxxx

PIC X(128) [default:none]

Name of the configuration file to be used by mfclient when called by mfserver as part of a cross-tier solution. Specifying this entry causes mfserver to act as a router passing data to a local mfclient module.

This mfclient module uses the configuration file to locate and communicate with another server. This allows protocols and communications API's to be changed across the machines used.

protocol=xxxxxx

PIC X(8) [default:CCITC32]

The CCI protocol to be used. This entry is applicable only if commsapi is set to CCI. You can specify any of the supported CCI protocols:

  • Novel IPX (enter CCIIX32)

  • NetBEUI (enter CCINB32)

  • Dynamic Data Exchange (enter CCIDE32)

  • TCP/IP (enter CCITC32)

If commsapi is set to CCI (the default setting ) and you do not specify a protocol, the client/server binding defaults to TCP/IP (CCITC32).

scrntype=xxxx

PIC X(4) [default:none]

Required interface indicator when multiple types are supported, that is, using the character control block to run both character and GUI interfaces. scrntype is not validated by the client/server binding modules

servername=xxx

PIC X(14) [default:MFCLISRV]

Servername to be used for communications.

setenv=name value

PIC X(148) [default:none]

Environment variable to be set on the server before the execution of any server programs. The format is:

variable name PIC X(20) variable value PIC X(128)

The name and value fields must be separated by at least one space and up to nine setenv entries can be specified.

srvanim=x

PIC X(16) [default:N]

Y or N. Setting this parameter to Y enables animation of the user programs running on the server. This means that mfserver does not have to be stopped and restarted with COBSW=+A as this is set up dynamically.

On UNIX systems only, you can specify a value of x,filename to enable cross-session animation of your programs. See the section Animating your Application for more details.

srverrprog=xxxxxx

PIC X(128) [default:none]

Name of program to handle communication errors instead of mfserver. The name 'SAME' will use the name set in the srvprog entry for mfserver errors.

srvprog=xxxxxx

PIC X(128) [default:custdata]

Name of user program to be called by mfserver.

srvtier=xxxxxx

PIC X(128) [default:mfserver]

This holds the name of the server tier program. When specified, it indicates that mfserver will be called by this program.

subserver=xxxx

PIC X(14) [default:none]

Basename of the server to be used for communications after the first contact with the main server instead of a name based on the initial servername. For example, the default servername is MFCLISRV and subservers will be named MFCLISRV00001, MFCLISRV00002..., but setting and entry of say NEWSERV here would result in subservers named NEWSERV00001, NEWSERV00002. This allows application specific subserver names to be used without the need to change the base server name.

timeout=nnnnn

PIC X(4) COMP-5 [default: 120 secs)

Use to override the system timeout default. The timeout period is specified in 1/10 (tenths) of a second. Previously issued calls retain the timeout period that was in use when they were originally invoked.

ublksize=nnnn

PIC X(4) COMP-X [default:0]

Size of optional user Data Block.

useraudit=x

PIC X [default:N]

Toggle to control the logging of client connect and disconnect details. When set, the following details are logged by both client and server:

Date, Time, connect/disconnect indicator, Servername, Machinename, and Protocol.

14.4.2.2 Minimum Required Configuration File Entries

The minimum number of entries required in the configuration files varies depending on which of the following factors are being used:

The following table shows the different entries needed for Dialog applications which are and are not using an existing Dialog System program as the server.

Not using a DS program as the server Using a DS program as the server
dblksize The size of the Data Block. The size of the Data Block.
srvprog The name of the program that mfserver calls to perform the server-side processing. This is the user program on the server machine (that is, the COBOL program performing data access and business logic).  
srvtier   The name of the program that the base server will spawn. By default, this is mfserver, which should be changed only if you wish to use an existing Dialog System program as the server. This existing program also contains the COBOL code to perform data access and business logic.
Cblksize The size of the Dialog System control block (if you are not using the ds-cntrl.r1 copybook). The size of the Dialog System control block (if you are not using the ds-cntr.r1 copybook).
Protocol   The protocol to use. For example, CCITC32 for TCP.

When running multiple servers, you must supply the name of the server to be used via the servername entry.

Any configuration file entries which are unset assume the specified default values.

If you are not using TCP/IP, you must set the protocol entry.

14.4.2.3 Locating The Configuration File

You can specify where to locate the configuration file. The mfclient and mfserver programs attempt to locate the configuration file in the following ways:

  1. They look for the MFCSCFG environment variable and use the supplied filename if one is specified.

  2. They examine the command line and use any filename defined there in preference to that supplied via the MFCSCFG environment variable.

  3. If MFCSCFG is not set or contains no value, or if no filename has been specified on the command line, the default name mfclisrv.cfg is assumed and searched for in the current directory.

  4. If mfclisrv.cfg is not found, the default settings for the configuration entries described earlier in this document will be used.

In each case a full path of up to 128 characters can be used to identify the location of the configuration file.

14.5 Connecting Your Client Program to mfclient

In order to create programs using the client/server binding, add code similar to that described below to your client and server programs, so they can control the connection correctly. The amount of code required is quite small. Comments have been included to help you understand what the code is doing.

WORKING-STORAGE SECTION.
COPY "mfclisrv.cpy".
LINKAGE SECTION.
COPY "DS-CNTRL.V1". 
COPY "CUSTOMER.CPB".
PROCEDURE DIVISION.
Client-Control SECTION.
*  The main loop is repeated until the connection with 
*  the server ends
    PERFORM UNTIL End-Connection
* 'lnk-client' holds the name 'mfclient'
*  The first time through we initialize the system and establish 
*  contact with the server.
    CALL lnk-client USING lnk-param-block
    EVALUATE TRUE
      WHEN start-connection
*  Make the DS control block and the customer Data Block 
*  accessible by assigning them address allocated by 'mfclient'.
            SET ADDRESS OF ds-control-block TO lnkcblock-ptr
            SET ADDRESS OF customer-data-block TO lnkdblock-ptr
*  Having successfully established contact with the server, we
*  complete local initialization and make the first call to 
*  Dialog System.
            PERFORM Setup-Scrnset
            PERFORM Call-Dialog-System 
         WHEN end-connection
            EXIT PERFORM
         WHEN OTHER
            PERFORM Call-Dialog-System
      END-EVALUATE
*  Check if the exit flag has been set by the user on the screen
      IF customer-exit-flg-true
         SET client-ending TO TRUE
      END-IF
   END-PERFORM
   STOP RUN.

Note: The client program has the Dialog System copybook in linkage and maps it to an address provided by the binding. This copybook has three other 01-level items which are not mapped. These are the Dialog System version number and the Data Block version number. The reason they are not mapped is that their values would not be picked up by mapping, and it is the values they contain that we need. You can hard code the Dialog System version number in the program, as this very rarely changes. The Data Block version number, however, does change, and putting a fixed value in your program means that you have to remember to update it whenever the screenset is modified. To make this easier, a support program used by the binding can extract the screenset version number for you and allow you to set it dynamically. To use this program, add the following items to working storage:

    01  ws-null             PIC X(4) COMP-X.
    01  ws-scrnset-ver      PIC X(4) COMP-X.
    01  ws-ret-stat         PIC X COMP-X VALUE 0.

Add the following to the Procedure Division where the screenset details are being set up. The screenset name being used must include the correct extension. You would set ds-version-no to 3 for extensions of .rs.

      MOVE "CUSTOMER.gs" TO ds-set-name
      MOVE 2 TO ds-version-no
      CALL "dsdblksz" USING
           ds-set-name
           ws-null
           ws-scrnset-ver
           ws-ret-stat
      END-CALL
      MOVE ws-scrnset-ver to ds-data-block-version-no

If you want to control the number of clients running an application, or you choose to handle error message displays yourself, add code similar to the following to your program's initial EVALUATE statement.

      WHEN TOO-MANY-CLIENTS
         PERFORM OVER-CLIENT-LIMIT
      WHEN COMMS-ERROR
         PERFORM SHOW-ERROR
...
  OVER-CLIENT-LIMIT SECTION.
      DISPLAY SPACES AT 0101 WITH BACKGROUND-COLOR 7
        "MAXIMUM NUMBER OF CLIENTS EXCEEDED - SESSION ENDED"
        AT 1012 WITH FOREGROUND-COLOR 4
        SET CUSTOMER-EXIT-FLG-TRUE
            CLIENT-ENDING TO TRUE
      EXIT.
  SHOW-ERROR SECTION.
      DISPLAY LNK-ERROR-LOC AT 2201
         LNK-ERROR-MSG AT 2301 WITH SIZE LNK-ERROR-MSG-LEN. 
  SHOW-ERROR-EXIT.
      EXIT.

If you want to handle asynchronous requests, add additional code similar to the following to the EVALUATE statement:

      WHEN START-CONNECTION
         PERFORM GET-USER-INPUT
         IF MAKE-ASYNC-REQUEST  <* USER ASYNCHRONOUS OPTION
           SET ASYNC-REQUEST TO TRUE
         END-IF
      WHEN ASYNC-OK
         SET TEST-ASYNC-RESULT TO TRUE
         PERFORM DELAY-LOOP
      WHEN ASYNC-INCOMPLETE
         DISPLAY "REQUEST STILL BEING PROCESSED " AT 1010
         PERFORM DELAY-LOOP
         SET TEST-ASYNC-RESULT TO TRUE
      WHEN RESULT-OK
         DISPLAY "REQUEST COMPLETED             " AT 1010
         PERFORM GET-USER-INPUT
      WHEN ASYNC-NOT-STARTED
      WHEN ASYNC-FAILED
         DISPLAY "ASYNCHRONOUS REQUEST FAILURE  " AT 1010
         PERFORM SHOW-ERROR
         PERFORM GET-USER-INPUT
      WHEN COMMS-ERROR
         PERFORM SHOW-ERROR

14.6 Connecting your Server Program to mfserver

WORKING-STORAGE SECTION.
LINKAGE SECTION.
    COPY "DS-CNTRL.V1".
    COPY "CUSTOMER.CPB".
    COPY "mfclisrv.cpy".
PROCEDURE DIVISION USING lnk-param-block.
Controlling SECTION.
*--------------------------------------------------------------*
*  Associate the Dialog System copy books with their location
*  within the CS binding parameter block
*--------------------------------------------------------------*
    SET ADDRESS OF ds-control-block TO lnk-cblock-ptr.
    SET ADDRESS OF customer-data-block TO lnk-dblock-ptr.
    EVALUATE TRUE
      WHEN start-connection
         PERFORM Program-Initialize
      WHEN customer-exit-flg-true
         PERFORM Program-Terminate
      WHEN OTHER
         PERFORM Program-Body
    END-EVALUATE.
    EXIT PROGRAM.

If you choose to handle error message displays yourself, add code similar to the following to your program's initial EVALUATE statement.

    WHEN COMMS-ERROR
       PERFORM SHOW-ERROR
       SHOW-ERROR SECTION.
           DISPLAY LNK-ERROR-LOC AT 2201
              LNK-ERROR-MSG AT 2301 WITH SIZE LNK-ERROR-MSG-LEN. 
       SHOW-ERROR-EXIT.
           EXIT.

14.7 Running a Client/Server Binding Application

The mfserver module is provided in .int code format so that it can be run as it is, generated into .gnt code, or linked with other programs to create executable modules (UNIX only).

The mfclient and mfserver modules are run as standard COBOL programs, with both the client and server components started manually.

When running an existing stand-alone program as a server, specify its name, in the srvtier configuration entry, as the program which the base server should run (srvtier). Communications are handled by a copy of the mfserver module renamed dsgrun created as follows:

For details on the cobconfig file and environment variable, see your UNIX COBOL documentation. For details on linking and building executable modules, see the documentation for your chosen COBOL development environment.

The main benefit of using an existing program as the server is that you can have an application which runs on a single PC or a PC network, and can be deployed as a client/server application simply by using the binding and providing a single user interface program.

To run the client/server binding, first start the server program and then start the client program.

The command line to start the server program on UNIX is:

cobrun mfserver [-b] [-p protocol] [-s server-name] [-v]

and on Windows and OS/2:

runw mfserver [-p protocol] [-s server-name] [-v]

where:

-b (UNIX only) allows you to run the server as a background process. The command line should be terminated with the ampersand (&) character. Any error messages produced by the server are stored in the log file, mfclisrv.log.
-p protocol specifies the communications protocol.
-s server-name indicates a server-name other than the default server-name MFCLISRV.
-v displays the mfclient version number.

The command line to start the client program is:

runw program-name [config-filename]

where:

program-name Specifies the name of the user interface program.
config-filename Specifies the name of the configuration file to be used.

The client searches for its configuration file, using the name specified by the MFCSCFG environment variable, then using the name specified on the command line. If neither exists, it searches for a configuration file called mfclisrv.cfg (in this case, you must have created a file of this name).

For further details on these and other configuration file entries or full details on locating the configuration file, see the section The Client/Server Binding Configuration File.

For full details on running COBOL programs, see your COBOL system documentation.

14.8 Animating Your Application

You can animate your client program using the standard animation facilities of Net Express.

You can animate your server program by setting a configuration file parameter, srvanim=y (see the section Possible Entries for the Configuration File).

On PC servers, the Animator is started automatically when a client connects to the server if srvanim=y is set.

On UNIX servers, the Animator is run on the terminal from which mfserver was started, and so requires mfserver to be running in foreground mode. This can cause problems as it is preferable to run mfserver as a background process. A further restriction is that only one user can animate through mfserver at any one time. These problems can be avoided by setting srvanim=x,filename where filename is a file created using the touch command. On the terminal that you want to use to display Animator output, set COBANIM_2=animator and then run the command:

anim filename

On the terminal that you want to use for your standard input and output, run your application in the normal way, having added srvanim=x,filename to your configuration file.

14.9 Managing the Server

The behavior of the server can be altered by running the program mfcsmgr and passing it the required parameters and values. These parameters can be divided into two groups:

14.9.1 Shutting Down mfserver

The spawned servers are terminated by the client program when the client makes a normal exit.

You must terminate the initial server program manually as it continues to run even if it has no clients.

14.9.2 Managing Authorization Passwords

To prevent accidental shutdown of an active server, it is possible to assign a password to each server. This password must be supplied before the server can be stopped or its parameters changed.

14.9.3 Setting the Maximum Number of Clients

The default number of clients the server can support is 65535, but you can set a lower limit using one of the mfcsmgr functions. The number you select is stored in the password file and will be used each time the server is started.

14.9.4 Enabling Server Override

The server can support override options for the server-name, protocol and machine-name. As the server does not use a configuration file, the override parameters are supplied using the mfcsmgr program.

This generates a short exchange between the client and the server which processes the selected function.

The mfcsmgr command line syntax for this is:

On Windows or OS/2 enter:

run mfcsmgr [-a] [-c nnnnn] [-d] [-i filename] [-m machine-name] 

[-p protocol] [-s server-name] [-o m,machinename]
[-o p,protocol] [-o r] [-o s,servername] [-t] [-v]

or on UNIX enter:

cobrun mfcsmgr [-a] [-c nnnnn] [-d] [-i filename] [-m machine-name] 

[-p protocol] [-s server-name] [-o m,machinename]
[-o p,protocol] [-o r] [-o s,servername] [-t] [-v]

where:

-a Changes the authorization password associated with the target server.
-c nnnnn Sets the number of clients the server can support.
-d Deletes local override file when client exists.
-i filename Installs the specified file in the client's local directory when the client exists.
-m machine-name Specifies the machine-name on which the target server is running. This is required if the same server-name is used on more than one platform.
-p protocol Specifies the communications protocol (for example CCITCP or CCITC32) being used.
-s server-name Indicates a server name other than the default MFCLISRV.
-o m, machinename Specifies the machine-name on which the overriding is running.
-o p, protocol Accesses the overriding server.
-o r Resets active override. Revert to original settings.
-o s, servername Overrides connections to the target server by directing them to this server.
-t Terminates the server.
-v Displays the mfclient version number.

All the above flags can be specified with a - or /, and are not case sensitive.

14.10 Advanced Topics

This section covers the following advanced topics:

14.10.1 Creating Audit Trails

The client/server binding allows you to create an audit trail of dates and times of clients connecting to servers. To enable this feature, simply set the 'useraudit=y' entry in your configuration file. This information is created in the system log file described in the section The System Error/Message Log.

14.10.2 Overriding Configuration File Entries

In the start-up process for each client, the client/server:

  1. Reads the configuration file.

  2. Searches the client/server binding for a file called mfcsovrd.cfg in the same location as the system log file. If the file is found, its contents will override any parameters previously set up using the configuration file.

    The format of the override file is the same as the standard configuration file, with the addition of the entry override-cntrl. This entry is used to indicate the subject of the override and can be:

The client override facility can be used, for example, if a server is unavailable and applications need to be run on another machine. You can change individual configuration files, but a single override file can be used to re-route any number of applications.

The override facility can also be used on the server, but in this case the server machine needs to be up and running. As before, either servernames or tagnames can be overridden.

An entry is added to the log file whenever an override file is detected and all parameters which are subject to the override process are logged.

The following example shows how the override facility can be used to re-route clients to another server:

[OVERRIDE-CNTRL]
OVERRIDE=SERVERNAME
[OLDSERVER]
SERVERNAME=NEWSERVER

In this example, the [override-cntrl] section specifies that the subject of the override is a servername (override=servername) and then, under the old servername ([oldserver]), the new servername (servername=newserver) is specified. This results in the following log file entries:

20/04/1997 11:01:02 Using Local File: mfcsovrd.cfg
Overriding Entries for Servername:OLDSERVER
servername=newserver
20/04/1997 11:01:02 Override Completed:

The following example shows how the override facility can be used to override the server being used by all those clients which are using a specified tag:

[OVERRIDE-CNTRL]
OVERRIDE=TAGNAME
[MF-CLISRV]
SERVERNAME=NEWSERV

In this example, the [override=cntrl] section specifies that the subject of the override is a tagname (override=tagname) and then, under the tagname ([mf-clisrv]), the parameter to be overridden (in this case the servername) is specified (servername=newserv). This results in the following log file entries:

20/04/1997 11:04:02 Using Local File: mfcsovrd.cfg
Overriding Entries for Tagname:MF-CLISRV
servername=newserver
20/04/1997 11:04:02 Override Completed:

14.10.3 Using the In-line Configuration Facility

One of the most powerful features of the client/server binding is the ability to control the communications requirements from configuration files. This does however mean that end users can affect the way an application runs by changing entries in these files. This may not be desirable. It is possible to provide all the parameters to an application in the client program. This means that the end user cannot alter the way an application behaves because it no longer uses a configuration file. Flexibility is maintained in that you still have no need to get into detailed communications code: you simply supply the required parameters within your client program.

The process is started by setting load-inlinecfg and completed by setting end-inline-cfg in your mfclisrv.cpy copyfile in your client program. Each parameter entry is loaded into the lnkerror-msg field and mfclient is called to process it. The parameters have to be supplied before the main processing loop is entered. See the example below.

WORKING-STORAGE SECTION.
01  ws-null          PIC X(4) COMP-X.
01  ws-scrnset-ver   PIC X(4) COMP-X.
01  ws-ret-stat      PIC X COMP-X VALUE 0.
COPY "mfclisrv.cpy".
01  dialog-system    PIC X(48). 
LINKAGE SECTION.
COPY "DS-CNTRL.V1". 
COPY "CUSTOMER.CPB".
PROCEDURE DIVISION.
 
Client-Control SECTION.
   SET load-inline-cfg TO TRUE
   MOVE "clierrprog=same" TO lnk-error-msg 
   CALL lnk-client USING lnk-param-block 
   
   MOVE "srverrprog=same" TO lnk-error-msg 
   CALL lnk-client USING lnk-param-block

   MOVE "servername=mainserv" TO lnk-error-msg 
   CALL lnk-client USING lnk-param-block
   
   SET end-inline-cfg TO TRUE
*  The main loop is repeated until the connection with *  the server ends 
   PERFORM UNTIL End-Connection
*  'lnk-client' holds the name 'mfclient'
*  The first time through we initialize the system and 
*  establish contact with the server.
      CALL lnk-client USING lnk-param-block
      EVALUATE TRUE
         WHEN start-connection
   ........ The rest of the program is standard from this
   ........... point onwards  ............

It is also possible to combine an external configuration file with the inline configuration facility. This is ideal because the end-user can modify the system to his own requirements, but the final control remains within the client program. The configuration file is processed first, followed by the inline entries. This means that any unwanted parameters supplied in the configuration file can be overridden by the inline entry. In this case the process is started by setting use-combined-cfg and completed as before by setting end-inline-cfg.

WORKING-STORAGE SECTION.
01  ws-null          PIC X(4) COMP-X.
01  ws-scrnset-ver   PIC X(4) COMP-X.
01  ws-ret-stat      PIC X COMP-X VALUE 0.
COPY "mfclisrv.cpy".
01  dialog-system    PIC X(48). 
LINKAGE SECTION.
COPY "DS-CNTRL.V1". 
COPY "CUSTOMER.CPB".
PROCEDURE DIVISION. 
Client-Control SECTION.
   SET use-combined-cfg TO TRUE
   CALL lnk-client USING lnk-param-block
   SET load-inline-cfg TO TRUE
   MOVE "servername=mainserv" TO lnk-error-msg 
   CALL lnk-client USING lnk-param-block
   SET end-inline-cfg TO TRUE
*  The main loop is repeated until the connection with *  the server ends 
   PERFORM UNTIL End-Connection
*  'lnk-client' holds the name 'mfclient'
*  The first time through we initialize the system and
*  establish contact with the server.
      CALL lnk-client USING lnk-param-block
      EVALUATE TRUE
         WHEN start-connection
   ....... The rest of the program is standard from this
   .......... point onwards  ............

14.10.4 Reduced Data Transfer Facility

Reduced Data Transfer (RDT) provides a way for you to control the amount of data being passed across the network and for you to limit this data to the absolute minimum required to achieve the desired result.

The client/server binding assigns a buffer large enough to hold the Data Blocks defined in the configuration file. This buffer is transferred back and forth whenever control is shifted between the client and server programs. This can impose a load on the network which some users may find unacceptable. Imagine you have a buffer of 24K which contains a 22K record area. If the file which holds these records has a 10 byte key, you can see that sending the key from client to server uses 24K when only 10 bytes are actually required. In reality, you need one or two bytes more than this, but it is much less than the size of the entire buffer.

RDT requires a control flag (use-rdt) and three parameters to be set in mfclisrv.cpy in your client program:

lnk-usr-fcode User function indicator. Lets the user server program know what to do with the data that has just arrived.
Lnk-usr-retcode Buffer start point. This indicates which of the four data areas will be used as the start point for the transfer:
1 Dialog System control block.
2 Data Block.
3 Dialog System event block.
4 User Data Block.

The numbers 11 through 14 can also be used and indicate the same address areas but use data compression on the transfer. Data compression must have been enabled via a configuration file entry, or the base (uncompressed) option will be used. A value of zero results in nothing being transferred. This allows you to have a NULL operation without changing the flow of your code by adding various IF statements. This is useful if you choose to process certain functions locally in order to further reduce network traffic.

Lnk-data-length The length of data to be transferred.

For example, consider an application which allows you to ADD, DELETE and LOAD customer details to and from an index file. The record key for the customer details is a customer code. The application also has a CLEAR option to clear all customer information from the interface. The application is the customer example program installed with this product. The code extract below is based on this example application, and we are using the user-data-block area to hold the record key which is six bytes long. The Data Block area (dblksize) used by the application to pass the customer record details between the client and the server is called customer-data-block. The data item customer-c-code is a 6-byte data item within customer-data-block and is used to store the record key.

On the client, the code would be similar to that shown below.

EVALUATE TRUE
    WHEN customer-load-flg-true
*  User has entered customer code and selected the "LOAD"
*  option on the interface to read and display the customer
*  details relating to that code.
    MOVE customer-c-code TO user-data-block
        SET use-rdt TO TRUE
        MOVE 1 TO lnk-usr-fcode
        MOVE 4 TO lnk-usr-retcode
        MOVE 6 TO lnk-data-length
    WHEN customer-del-flg-true
*  User has entered a customer code and selected the DELETE 
*  option to delete the customer record from the file.
    MOVE customer-c-code TO user-data-block
        SET use-rdt TO TRUE
        MOVE 2 TO lnk-usr-fcode
        MOVE 4 TO lnk-usr-retcode
        MOVE 6 TO lnk-data-length
        INITIALIZE customer-data-block
    WHEN customer-clr-flg-true
*  User has selected the CLEAR option to clear the current
*  customer details from the screen.
    SET use-rdt TO TRUE
        MOVE 0 TO lnk-usr-retcode
        INITIALIZE customer-data-block
        PERFORM Set-Up-For-Refresh-Screen
END-EVALUATE

The CLEAR option uses a NULL operation because clearing the record is done locally so there is no need to contact the server. Below is an extract from the server program showing the code required to process RDT. The client/server binding sets the flag "send-via-rdt" so you can check the values of lnk-usr-fcode. On the server, the code would be similar to that shown below.

WHEN send-via-rdt
    EVALUATE lnk-usr-fcode
        WHEN 1
*  For the LOAD function, the server program reads the customer
*  details from the data file, and sends the data back to the client
*  using the data area customer-data-block rather than using
*  the RDT facility. Unless the RDT flag is set, the client/server
*  bindings will always pass the complete data area (defined by
*  dblksize in the configuration file) between the client and the
*  server.
        MOVE user-data-block TO customer-c-code
            SET customer-load-flg-true TO TRUE
            PERFORM... .rest of program... .
        WHEN 2
            MOVE user-data-block TO customer-c-code
            SET customer-del-flg-true TO TRUE
            PERFORM... .rest of program... .
    END-EVALUATE

14.10.5 Server Controlled File Management Facility

One of the problems that accompanies any client/server solution, especially as the number of clients increases, is the management of client program updates and other changes.

The override facility (see the section Overriding Configuration File Entries) enables you to re-route client applications while server maintenance is carried out without having to change each client's configuration file entries. The override can be either local or remote, but installing and removing a local override file on each client can be time-consuming.

The mfcsmgr program enables you to install and delete override files on the client using the -i and -d options respectively. See the section Managing the Server. The install/delete is carried out as the client program exits.

In fact, the -i option of the mfcsmgr program enables you to install any type of file on the client system (in the client's local directory). This means that you can use it to install new screensets or program files, enabling updates to be distributed from a central point. For security reasons, the delete option has not been similarly enhanced: it will delete an override file only; that is, a file called mfcsovrd.cfg.

Files to be installed using the -i option must be located on the server. If the file is in the directory from which mfserver was started, you need only specify the filename. If it is anywhere else, you must supply a full pathname in such a way that the filename can be extracted from the path. For example, /u/live/update/newprog.int, d:\testprog.int and $LIVE/newtest.int are all valid, but $newfile is not.

No programming changes are required to use these functions. A message is displayed informing the client that a file is being transferred and the details are recorded in the system log file.

14.11 Running the Supplied Customer Example

See the file csbind.txt in the DialogSystem\demo\csbind directory for instructions on how to run the Dialog System client/server binding demonstration.

14.12 The System Error/Message Log

Both the client and server modules of the binding maintain a log of errors and messages. All entries are date- and time-stamped and are kept in a file called mfclisrv.log, which is written to the directory in which the programs were started or to the directory named in the MFLOGDIR environment variable. Check this log from time to time to ensure that your system is performing correctly.

14.13 Client/Server Binding Limitations

The client/server binding imposes very few limitations, but you should be aware of the following issues:


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousUsing Panels V2 Advanced TopicsNext