# mco_cluster_listen

This is the main function implementing cluster functionality. It is a blocking function, so it should be called in a separate thread.

### For an overview see page Cluster Applications in C

### Prototype

        MCO_RET	mco_cluster_listen (	/*IN*/ mco_db_h db )

### Arguments

db | connection to database

### Description

This function receives messages from other nodes, executes remote transactions, monitors the status of the local transactions, sends a keep-alive message, and other responsibilities. It is a blocking function, so it should be called in a separate thread. This thread must be started immediately after the `mco_cluster_db_open()` call, on each cluster node.

### Return Codes

MCO_S_OK | The cluster has been properly initialized. In this case all nodes will contain identical copies of the database
MCO_E_CLUSTER_NOQUORUM | Some nodes were down, and the remaining nodes do not constitute a quorum
MCO_E_CLUSTER_NOT_INITIALIZED | The database was not created by mco_cluster_db_open(). Note: it may have been created by `mco_db_open_dev()` by mistake
MCO_E_CLUSTER_PROTOCOLERR | Protocol error during transaction replication

### Files

Header file:
mcocluster.h
Source file:
mcocluster.c
Library:
libmcocluster.a