The management of connections by client applications covers the mechanisms by which a merged client application connects to the target server, once it is in its production environment, including in case of connection error.
In binary databases, the mechanisms described on this page are enabled only when the Use new architecture for application deployments option on the "Compatibility" page of the Database Settings dialog box is checked (see the Compatibility page section).
The connection procedure for merged client applications supports cases where the dedicated server is not available. The startup scenario for a 4D client application is the following:
- If valid connection information is stored in the EnginedServer.4DLink file within the client application, the client application connects to the specified server address.
OR
The client application tries to connect to the server using the discovery service (based upon the server name, broadcasted on the same subnet).
Compatibility note: When the compatibility option is not checked (see the Compatibility section), if a failure occurs at this stage, the standard "Server connection" dialog box is displayed directly. - If this fails, the client application tries to connect to the server using information stored in the application's user preferences folder (lastServer.xml file, see last step).
- If this fails, the client application displays a connection error dialog box.
- If the user clicks on the Select... button (when allowed by the 4D developer at the build step, see below), the standard "Server connection" dialog box is displayed.
- If the user clicks on the Quit button, the client application quits.
- If the connection is successful, the client application saves this connection information in the application's user preferences folder for future use.
The whole procedure is described in the following diagram:

The last used and validated server path is automatically saved in a file named lastServer.xml in the application's user preferences folder. This folder is stored at the following location:
Compatibility note: When this compatibility option is not checked (see the Compatibility section), the path is not saved.
This mechanism addresses the case where the primary targeted server is temporary unavailable for some reason (maintenance mode for example). When this case occurs for the first time, the server selection dialog box is displayed (if allowed, see below) and the user can manually select an alternate server, whose path is then saved if the connection is successful. Any subsequent unavailability would be handled automatically through the lastServer.xml path information.
Notes:
- When client applications cannot permanently benefit from the discovery service, for example because of the network configuration, it is still recommended that the developer provide a host name at build time using the IPAddress key in the BuildApp.xml file. The new mechanism addresses cases of temporary unavailability.
- Pressing the Alt/Option key at startup to display the server selection dialog box is still supported in all cases.
- To allow several merged clients with the same name and on the same machine to connect to their own servers, set the ClientUserPreferencesFolderByPath key to True at build time. This will ensure each merged client application has its own folder in the user preferences folder and connects to the right server.
You can choose whether or not to display the standard server selection dialog box on merged client applications when the server cannot be reached.
In this case, the configuration depends on the Use new architecture for application deployments compatibility option (see the Compatibility section) as well as the value of the ServerSelectionAllowed XML key on the machine where the application was built. There are three possibilities:
- Display of an error message with no access possible to the server selection dialog box
Default operation for databases created starting with 4D v15 R4.The application can only quit. This functioning is obtained with the following configuration:
- Use new architecture for application deployments option: checked
- ServerSelectionAllowed XML key: value False or key omitted

- Display of an error message with access to the server selection dialog box possible
The user can access the server selection window by clicking on the Select... button. This functioning is obtained with the following configuration:
- Use new architecture for application deployments option: checked
- ServerSelectionAllowed XML key: value True
=> 
- Direct display of server selection dialog box
Legacy behavior in binary databases created with versions prior to 4D v15 R4 (binary databases). It is obtained with the following configuration:
- Use new architecture for application deployments option: unchecked
- ServerSelectionAllowed XML key: ignored

Note: For more information about the ServerSelectionAllowed XML key, refer to its description in the 4D XML Keys BuildApplication manual.