PublicShow sourcemqi.pl

Source mqi_start(+Options:list) is semidet
Starts a Prolog Machine Query Interface ('MQI') using Options. The MQI is normally started automatically by a library built for a particular programming language such as the swiplserver Python library, but starting manually can be useful when debugging Prolog code in some scenarios. See the documentation on "Standalone Mode" for more information.

Once started, the MQI listens for TCP/IP or Unix Domain Socket connections and authenticates them using the password provided (or created depending on options) before processing any messages. The messages processed by the MQI are described below.

For debugging, the server outputs traces using the debug/3 predicate so that the server operation can be observed by using the debug/1 predicate. Run the following commands to see them:

Source mqi_version(?Major_Version, ?Minor_Version) is det
Provides the major and minor version number of the protocol used by the MQI. The protocol includes the message format and the messages that can be sent and received from the MQI.

Note that the initial version of the MQI did not have a version predicate so The proper way for callers to check the version is:

use_module(library(mqi)), ( current_predicate(mqi_version/2) -> mqi_version(Major_Version, Minor_Version) ; Major_Version = 0, Minor_Version = 0 )

Major versions are increased when there is a change to the protocol that will likely break clients written to the previous version. Minor versions are increased when there is new functionality that will not break clients written to the old version

This allows a client written to MQI version 'Client_Major_Version.Client_Minor_Version' to check for non-breaking compatibility like this:

Client_Major_Version = MQI_Major_Version and Client_Minor_Version <= MQI_Minor_Version

Breaking changes (i.e. Major version increments) should be very rare as the goal is to have the broadest adoption possible.

Protocol Version History:

Source mqi_start is semidet
Main entry point for running the Machine Query Interface in "Embedded Mode" and designed to be called from the command line. Embedded Mode is used when launching the Machine Query Interface as an embedded part of another language (e.g. Python). Calling mqi_start/0 from Prolog interactively is not recommended as it depends on Prolog exiting to stop the MQI, instead use mqi_start/1 for interactive use.

To launch embedded mode:

swipl mqi --write_connection_values=true

This will start SWI Prolog and invoke the mqi_start/0 predicate and exit the process when that predicate stops. Any command line arguments after the standalone -- will be passed as Options. These are the same Options that mqi_start/1 accepts and are passed to it directly. Some options are expressed differently due to command line limitations, see mqi_start/1 Options for more information.

Any Option values that cause issues during command line parsing (such as spaces) should be passed with "" like this:

swipl mqi --write_connection_values=true --password="HGJ SOWLWW"

For help on commandline options run

swipl mqi --help
Source mqi_stop(?Server_Thread_ID:atom) is det
If Server_Thread_ID is a variable, stops all Machine Query Interfaces and associated threads. If Server_Thread_ID is an atom, then only the MQI with that Server_Thread_ID is stopped. Server_Thread_ID can be provided or retrieved using Options in mqi_start/1.

Always succeeds.