company logo

Client :: connect - Connect to server

This function establishes a connection to an ODABA server. When not connecting the client to a server, the client runs in local mode. When running in local mode all resources are located on the client machine or in a local network (LAN).

When being connected to a server you can access resources located on the server or on the local machine by setting the local_resources parameter when constructing dictionary or database handles.

When connecting several times, for closing the connection you have to disconnect as often as you have connected to the server. When the client is connected once it cannot be connected to another server until the opened connection is closed. When trying to connect a client already connected to another server, the function throws an exception.

When the server supports connection cache, one may pass a unique connection identification in sConnectionName . This will keep the connection open for your application and provides fast reconnection. Associating the connection with a unique connection identifier will prevent the connection from being reused by other applications.

When no server connection could be established, the function throws an exception.

Notes:

Replication servers do not need an explicit connect. Working with an replication server will connect to the server when opening the database.

Connections are cached automatically, when the option CONNECTION_NAME has been set before connecting to the server ( connect() ) or when it has been defined in the application's configuration file.

Implementation details

Client  :: connect ( odaba::String &sServerName, int32 iPort, odaba::String &sConnectionName )
  • sServerName - Server name

    Valid server name or IP address referring to the server in a client server application.

  • iPort - Port number

    The port number must be the same the server has been started with (e.g. 6123). When no port number is passed, the client expects the port number being defined in a system variable SERVER_PORT or in a system environment ini-file on the ODABA installation folder.

  • sConnectionName - Connection name

    This is a unique connection name assigned to the connection. When caching connections (e.g. when running WEB applications), connections are not closed when a client disconnects. The connection name is used for fast client reconnect. Moreover, the client session on the server side is able to maintain client states while the client is not closed.