* Each client provides a session class or script with methods to connect to and communicate with the database server. A socket connection will be established by the constructor, which expects a host, port, user name and password as arguments.
* The {{MonoCode|execute()}} method is called to launch a database command. It returns the result or throws an exception with the received error message.
* The {{MonoCode|query()}} method creates a query instance. Variables can be bound to that object, and the result can either be requested via {{MonoCode|execute()}}, or in an iterative manner with the {{MonoCode|more()}} and {{MonoCode|next()}} functions. If an error occurs, an exception will be thrown.
* The {{MonoCode|create()}}, {{MonoCode|add()}}, {{MonoCode|replace()}} and {{MonoCode|store()}} method pass on input streams to the corresponding database commands.
* To speed up execution, an output stream can be specified by some clients; this way, all results will be directed to that output stream.
===Query Command Protocol===
Queries are referenced via an {{MonoCode|id}}, which has been returned by the {{MonoCode|QUERY}} command (see above):
{| class="wikitable"
| <code>\4 {id}</code>
| <code>\x {item} ... \x {item} \0</code>
| Returns all resulting items as strings, prefixed by a [[Server Protocol: Types|Type]] byte ({{MonoCode|\x}}).
|-
| EXECUTE
| <code>\30 {id}</code>
| <code>{result} \0</code>
| {{Version|7.2}}: Returns {{MonoCode|true}} if the query may perform updates; {{MonoCode|false}} otherwise.
|-
| FULL
===XDM Meta Data===
In most cases, the ''XDM'' meta data boils down to a single byte, which represents the [[Server Protocol: Types|node kind or item type]]. There are three exceptions: {{MonoCode|document-node()}}, {{MonoCode|attribute()}} and {{MonoCode|xs:QName}} items are followed by an additional <code>{URI}</code> string.
==Examples==