mco_iot_comm_next_conn

Return the next active connection for this communicator.

For an overview see page ARF Applications in C

Prototype

 
    iot_connection_h mco_iot_comm_next_conn(mco_iot_comm_h comm, 
                            iot_connection_h prev) ;
 

Arguments

comm The communicator object
prev The previous connection

Description

This function returns the next connection for this communicator and automatically calls mco_iot_conn_release() for the previous connection prev. This function can be used to list all active connections, but the order in which they are listed is undefined. Note that the mco_iot_comm_find_conn() and mco_iot_comm_next_conn() APIs “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

iot_connection_h The next connection for this communicator or NULL if none found

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 connection 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