Receive connection statistics.
MCO_RET mco_iot_conn_get_stat(mco_iot_connection_h iotc, mco_iot_connection_stat_t *stat);
iotc | The connection handle (iot_connection_h ) |
stat |
The connection statistics structure: typedef struct mco_iot_connection_stat_t_ { mco_inetaddr_t inetaddr; /* peer IP */ int port; /* peer port */ uint8 sent_bytes; /* TX bytes */ uint8 recv_bytes; /* RX bytes */ } mco_iot_connection_stat_t; |
This function receives a mco_iot_connection_stat_t
structure (see above) with connection statistics in argument stat
.
MCO_S_OK | Connection statistics successfully returned |
MCO_E_IOT_INVALID_HANDLE | The connection handle iotc is invalid |
{ // Get statistics for agent_id mco_iot_connection_stat_t cstat; mco_iot_connection_h conn = mco_iot_comm_find_conn(comm, agent_id); mco_iot_conn_get_stat(conn, &cstat); mco_iot_conn_release(conn); // Print out cstat values ... }