mco_edge_connect

Establishes a connection to an edge database instance.

For an overview, see the Edge Client page.

Prototype

    MCO_RET mco_edge_connect(const char *db_name, mco_edge_h *con);
    

Arguments

db_name
Null-terminated string specifying the name of the edge database instance to connect to. Must match the name used in the corresponding mco_edge_open() call.
con
Pointer to an mco_edge_h handle that will receive the connection reference. This handle is thread-local and must not be shared between threads.

Description

Establishes a connection to an edge database instance previously created by mco_edge_open(), analogous to mco_db_connect() in the core runtime.

Each thread that interacts with an edge database must obtain its own connection handle via mco_edge_connect(). Connection handles (mco_edge_h) are not thread-safe and must not be shared across threads.

The edge client uses a lightweight connection model optimized for resource-constrained environments. Once connected, the application can perform transactions, insert data, and synchronize with the server using the returned handle.

Related types:

Return Codes

MCO_S_OK
Connection established successfully.
MCO_E_ILLEGAL_PARAM
One or more parameter values are invalid (e.g., NULL db_name or con).
MCO_E_SESLIMIT
Maximum number of concurrent connections exceeded (as specified in mco_edge_params_t::max_connections).
MCO_E_NOINSTANCE
No edge database instance with the specified db_name exists.

Files

Header file:
mcoedge.h
Source file:
mcoedgedb.c
Library:
libmcoiotedge.a