# mco_iot_conn_release

Release the connection.

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

### Prototype

        MCO_RET mco_iot_conn_release(iot_connection_h iotc);

### Arguments

iotc | The connection handle (`iot_connection_h`)

### Description

This function releases the connection. When the `mco_iot_comm_find_conn()` and `mco_iot_comm_next_conn()` APIs are used they “lock/pin” the connection handle to protect the handle from being destroyed. When the handle is no longer needed, the “pin” should be removed by calling `mco_iot_conn_release()`. The safer way to enumeration active connections (from the "pin/unpin" standpoint) is to use the `mco_iot_replicator_enum_agents()` API.

### Return Codes

MCO_S_OK | Connection successfully released
MCO_E_IOT_INVALID_HANDLE | The connection handle `iotc` is invalid

### Example

        conn = 0;
        while ((conn = mco_iot_comm_next_conn(comm, conn)))
        {
            // if prev == 0 - start over;  _next_conn() automatically calls release() for the previous connection
            // do something with conn
            if (!condition)
            {
                break;
            }
        }
        if (conn)
        {
            mco_iot_conn_release(conn); // explicitly release connection
        }

### Files

Header file:
mcoiot.h
Source file:
mcoiotcomm.c
Library:
libmcoiotcomm.a