Return the next active connection for this communicator.
iot_connection_h mco_iot_comm_next_conn(mco_iot_comm_h comm,
iot_connection_h prev) ;
| comm | The communicator object |
| prev | The previous connection |
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 API.mco_iot_replicator_enum_agents()
| iot_connection_h | The next connection for this communicator or NULL if none found |
{
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
}
}